Flic Home

    Community

    • Login
    • Search
    • Popular
    • Users
    1. Home
    2. pico
    3. Posts
    • Profile
    • Following 0
    • Followers 0
    • Topics 11
    • Posts 27
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by pico

    • RE: Release of MQTT client

      I've got a Flic Hub LR running a module that uses this MQTT client. After a router reboot, the client never reconnected, and every publish failed with Cannot call write after a stream was destroyed.

      The client only handles the socket's end event, so when the connection drops without a clean end it stays connected and never emits disconnected. I posted an issue on GitHub with a four line fix (handling close as well): https://github.com/50ButtonsEach/flic-hub-sdk-mqtt-js/issues/4

      posted in Flic Hub SDK
      pico
      pico
    • Feature Request: Expose the Matter Electrical Power Measurement (0x0090) and Power Topology (0x009C) Clusters

      I've got a Flic Hub LR on firmware 4.6.4 with some Tapo P110M smart plugs paired over Matter (Tapo firmware 1.4.4, Matter SoftwareVersionString 1.3.0). Their endpoint 1 ServerList is [3, 4, 6, 29, 144, 145, 156], but the Matter module only seems to expose Electrical Energy Measurement (0x0091), not Electrical Power Measurement (0x0090) or Power Topology (0x009C).

      Subscribing with clusterName: 'Electrical Power Measurement' throws Cluster "Electrical Power Measurement" not found, and clusterId: 144 throws Cluster id 144 not found. A whole-node subscription ([{}]) delivers every other cluster, but nothing from 0x0090 or 0x009C.

      Would it be possible to expose 0x0090 (ActivePower and its other measurements) and 0x009C in the Matter module, or to allow reading any cluster by ID? That would let modules read live power from Matter plugs, instead of estimating it from Electrical Energy Measurement's periodic energy windows.

      posted in Flic Hub SDK
      pico
      pico
    • RE: Recently Saved Module Script Lost If Hub Loses Power

      Also, out of curiosity, what is the storage capacity on the Flic Hub LR? I have a database that is logging Matter connection/disconnection events and curious if/when it would get too large and mess things up.

      posted in Flic Hub SDK
      pico
      pico
    • RE: Recently Saved Module Script Lost If Hub Loses Power

      @Emil thanks for the info.

      I do mean power cycling by unplugging and replugging.

      Would it be possible to add some way to force an immediate sync (maybe upon disconnect from Hub Studio if that doesn't sync already, I usually just leave the web page with it still connected)? Or to do a graceful reboot with a button in Hub Studio or via Flic app which syncs properly?

      I was doing reboot in connection with my testing on the Thread issue that I posted about. It seems sometimes I can bring the Thread connection back by rebooting Flic Hub.

      posted in Flic Hub SDK
      pico
      pico
    • Recently Saved Module Script Lost If Hub Loses Power

      I've got a Flic Hub LR on firmware 4.6.0. I've noticed if I reboot the hub within a couple minutes after saving a module file I've just edited that the file can be completely empty or incomplete after the reboot.

      But, if I reboot 10min or more after saving, the files are intact. I haven't noticed the same issue with a module's datastore.db contents which seem to stay intact even when edited shortly before the reboot.

      Is there some delay before a saved script file is flushed to storage?

      posted in Flic Hub SDK
      pico
      pico
    • Flic Hub LR 4.6.0 drops a Thread lock when a command times out, and after about 10 minutes idle

      I've got a Flic Hub LR on Firmware 4.6.0 connected via Ethernet. It has been a reliable Matter controller for 47 Wi-Fi devices, but my one Thread device has been flakey via Flic.

      • Ultraloq Bolt Fingerprint lock (battery, Matter over Thread), firmware 02.37.0028. Multi-admin: Apple Home, SmartThings, Flic Hub.
      • Thread border routers: two HomePod minis and an Apple TV 4K (27.2); two SmartThings Hub v3 (000.062.00016, separate Thread network, no devices).
      • Measured with a Hub SDK module: Identify (IdentifyTime 0), reachable from getNodes() and nodeUpdate, connected from matter.subscribe().

      I've see that a command that times out drops the node: sendCommand calls back after 70 to 175s (50: CHIP Error 0x00000032: Timeout where recorded), and the node goes unreachable in the same second. Eight times today. With nothing sent, the node dropped 10 minutes after the last answered command. After a drop, sendCommand fails in about 50ms with 72: node not connected, for minutes to hours. Today, answered commands took 44 to 112s. Ping to the lock through each border router works and takes about 2.7s. The node reported reachable and connected for 14 minutes, then the first command failed in 153ms with error 72 and then the flags go false. A hub restart reconnects the node within about 20s, but the first command after 7 of 8 restarts today failed and dropped it again. Last night, a test command running every 3 minutes all answered for 1.5h, until an automatic router reboot, and then connected never returned, though commands succeeded for another 3h. Today, most commands timed out, at intervals of 3, 7 and 15 minutes. Throughout all the issues via Flic, Apple Home and SmartThings continue control the lock, and all border routers announce its Thread prefix. Rebooting Thread hubs, battery pulls and re-adding the lock to the Flic Hub did not help.

      Is this a known issue? Are there any logs I can collect or more details I can provide?

      posted in Flic Hub
      pico
      pico
    • RE: Flic Duo Position Detection (On the Wall vs Handheld)

      @Emil Thank you!!!

      posted in Flic Hub SDK
      pico
      pico
    • Flic Duo Position Detection (On the Wall vs Handheld)

      I would like to be able to determine if a Flic Duo is on the wall or handheld in FlicScript.

      I see there is gesture and orientation (x, y, and z dict) attributes, but I'm not certain exactly what orientation parameters are best to accurately determine if a Flic Duo is currently mounted on the wall.

      Is it possible to add a definitive position attribute (or something similar gesture) to know if a Flic Duo is currently on the wall? Or, would it be possible to share the exact orientation conditions that y'all use internally when someone configures an action through the app to determine if the Flic Duo is on the wall or handheld?

      posted in Flic Hub SDK
      pico
      pico
    • RE: Crash with MQTT

      I just noticed this post https://community.flic.io/topic/18577/mqtt-issue-on-firmware-version-4-4-5 and updated Flic Hub to version 4.4.6 which appears to have solved the crash.

      posted in Flic Hub SDK
      pico
      pico
    • Crash with MQTT

      I have been using MQTT properly with the following code for a long time, and then yesterday I noticed my buttons weren't responding and when checking the Flic Hub Studio console I see that my script is crashing over and over again when running mqttClient.connect() with the following error:

      TypeError: Invalid type
          at invoke (native)
          at connectWithHostAndPort (core.js:1273)
          at <anonymous> (core.js:1332)
          at func (core.js:2325)
          at nextTickHandler (core.js:2334)
      

      Here is my whole MQTT code, and I am using the latest version of mqtt.js that is posted on https://github.com/50ButtonsEach/flic-hub-sdk-mqtt-js

      const mqttClient = require('./mqtt').create(mqttBroker, {username: mqttUsername, password: mqttPassword}) // https://github.com/50ButtonsEach/flic-hub-sdk-mqtt-js
      
      mqttClient.on('connected', () => {
      	console.log(`Connected to MQTT Broker ${mqttBroker}`)
      	mqttClient.subscribe('[TOPIC]')
      })
      
      mqttClient.on('disconnected', () => {
      	throw new Error(`DISCONNECTED from MQTT Broker ${mqttBroker}`) // Error to restart script if disconnected from MQTT broker.
      })
      
      mqttClient.on('publish', (pub) => {
      	console.log(`\nReceived MQTT Message on Topic: ${pub.topic}\n${pub.message}`)
      
      	// Handle button actions here.
      })
      
      mqttClient.connect()
      setInterval(() => { if (!mqttClient.connected) throw new Error('MQTT Broker NOT CONNECTED') }, 900000)
      // Check every 15 minutes that MQTT Broker is connected, and throw error to restart script if not.
      // This check is important if fails to connect to MQTT Broker at launch, when the "disconnected" event would never be sent.
      
      posted in Flic Hub SDK
      pico
      pico
    • RE: Can FlicScript Add Support for Local Timezones (with DST)

      @Emil Thanks for getting back to me. So no chance on adding Intl.DateTimeFormat API support to FlicScript or including a way to set the timezone in the app that is passed down into FlicScript?

      posted in Flic Hub SDK
      pico
      pico
    • Can FlicScript Add Support for Local Timezones (with DST)

      One of my scripts changes brightness based on the current time. I've noticed that FlicScript always uses UTC time, and there is no way to set a timezone in the app or even in code. When using new Date().toLocaleString('en-US', {timeZone: 'America/Los_Angeles'}) the UTC date is still returned.

      It isn't too hard to just get the UTC time and change the hours offset manually (which I'm currently doing), but it becomes a hassle when changes with Daylight Savings Time is factored in.

      Would is be possible to add a way to set the timezone in the app or something so that new Date() returns the date in the specified timezone (or the current location and timezone could be detected automatically), or at least make toLocaleString work properly so timezones can be adjusted manually an have DST accounted for automatically.

      Thank you!

      posted in Flic Hub SDK
      pico
      pico
    • RE: Matter writeAttribute Crashing

      @Emil Looks like it's fixed in 4.4.1, thank you so much!

      Out of curiosity, is there a set time that the Flic Hub LR auto-checks and installs updates? Also, there a log of update history on the device to see when updates were installed? And is there a changelog available anywhere?

      posted in Flic Hub SDK
      pico
      pico
    • RE: Matter writeAttribute Crashing

      @Emil Awesome, thank you so much!

      I'm glad this was easy to track down. I'm curious, is there any explanation as to how this popped up in previously working code when no firmware updates were done in the meantime? Does the Flic Hub LR have other OTA updates to the SDK runtime that are separate from the device firmware?

      posted in Flic Hub SDK
      pico
      pico
    • Matter writeAttribute Crashing

      Starting at least last night, using any writeAttribute Matter method started erroring with an uncatchable exception which completely crashes the script.

      This exact kind of code worked at least a week ago (maybe even earlier yesterday), and then last night when I was working on some changes I noticed a new crash that was not happening within my code.

      I'm not sure what would have caused this as I don't think my Matter devices had any firmware updates, nor the Flic Hub LR getting a firmware update.

      It appears that the attribute is getting set, but something after that point in underlying Flic code is not expecting a Success value.

      EXAMPLE CODE:

      const matterModule = require('matter')
      const matterDevices = matterModule.getNodes()
      
      const matterDeviceIDsForNames = {}
      for (const thisMatterDevice of matterDevices) {
      	matterDeviceIDsForNames[thisMatterDevice.name] = thisMatterDevice.nodeId
      }
      
      const thisMatterDeviceID = matterDeviceIDsForNames['Living Room Corner Lamp']
      
      const brightnessPercentage = 80
      const brightnessLevel = Math.round(254 * (brightnessPercentage / 100))
      
      matterModule.writeAttribute(thisMatterDeviceID, 1, 'Level Control', 'OnLevel', brightnessLevel, () => {})
      

      ERROR OUTPUT:

      SyntaxError: unexpected token: 'Success'
          at <input>:1
          at parse (native)
          at handlePacket (core.js:3259)
          at onPipeData (core.js:3336)
      
      posted in Flic Hub SDK
      pico
      pico
    • RE: Flic Hub LR as MQTT Broker?

      @Emil So you're saying it's not an existing capability in mqtt.js on https://github.com/50ButtonsEach/flic-hub-sdk-mqtt-js and it is something I would have to write myself?

      posted in Flic Hub SDK
      pico
      pico
    • Flic Hub LR as MQTT Broker?

      Can the Flic Hub LR itself be an MQTT broker to not need another piece of hardware if I just want the Flic Hub LR to subscribe and respond to MQTT messages from other sources? This way, I could use the Flic Hub LR as basically an MQTT-to-Matter bridge without needing another Raspberry Pi running as the MQTT broker.

      posted in Flic Hub SDK
      pico
      pico
    • RE: Cross-Module Persistent Data Storage

      @Emil It would be awesome if you all could add a Global Datastore in the future! If you need any help testing, I would be happy to play with a beta version!

      The Govee lights I'm working with are an older model H7013 which are warm white dimmable string lights that support Wi-Fi and Bluetooth, but that means the integrations are pretty limited to IFTTT which can be slow, and I can't detect the current state. The LAN API is much faster and I can check the current state, which is great.

      I've looked into upgrading to newer Matter versions from Govee or anyone else but they are all more expensive than is worth it for me when what I have it working, and many newer models have more features/complexity than I really want (don't want RGB or anything, just want 2700K warm white and dimmable).

      posted in Flic Hub SDK
      pico
      pico
    • Cross-Module Persistent Data Storage

      I'm curious if there is any way to have any data storage available across modules. datastore module is available, but it is per-module (looks like it makes a SQLite DB within the module).

      I would like the be able to have an IP address discovered from one module available to another.

      For the background, I am using the UDP/dgram module to control Govee lights via their LAN API (which is something I've always wanted to play with and the Flic Hub LR made it so easy, thank you!!!). I have one module (we'll call it Module A) which is bound to a port which allows me to listen for a response from a Multicast message which contains the IPs of the Govee lights. I do some controls to the lights within that Module A, but I also want to be able to control the lights from within another module (Module B), which just requires the IPs and doesn't need to do all the overhead of listening to responses. But these IPs aren't static and I was wanting to be able to log/store the IPs from Module A and access them from Module B so that I don't have to manually update Module B whenever the IPs change. Is this possible in any way? Thank you!

      posted in Flic Hub SDK
      pico
      pico
    • RE: FlicScript Matter Examples

      PS. For anybody finding this in the future, I also tried setting the StartUpCurrentLevel attribute and that behaves the same as calling MoveToLevel with OptionsOverride set to 1 when the light is off, Matter honors it when turned back on, but Tapo does not.

      posted in Flic Hub SDK
      pico
      pico