Flic Home

    Community

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

    Posts made by 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
    • RE: FlicScript Matter Examples

      @Emil Neat! I am seeing that setting MoveToLevel with OptionsOverride set to 1 does set the brightness when the light is off when it is turned back on via Matter, such as in the Apple Home app (which is something I've never been able to do via any exposed app controls). But, oddly Tapo itself seems to not honor that setting if I turn the light back on via the Tapo app, or more importantly via the wall switch. Seems like a Tapo quirk/bug and not an issue with FlicScript since it seems the setting is properly honored within the Matter protocol.

      From poking around more, I found the OnLevel attribute which looked interesting and I was able to set that with matterModule.writeAttribute(thisMatterDeviceID, 1, 'Level Control', 'OnLevel', brightnessLevel, () => {}). This appears to basically do what I want when the light is off, it will always get turned on to the specified brightness level. This has the effect of not keeping a manually set brightness, after the light is turned off and back on it will turn on to the specified OnLevel brightness instead of the previously manually set brightness, but I think that is actually totally fine for my desires in this project.

      This is so much fun to be able to work with Matter devices at such a low level! I really appreciate your advice and help with this all!

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

      @Emil About needing the current state on demand rather than listing for updates... I want to write a script to adjust the brightness of lights throughout the day (dimming them hourly throughout the evening). This is also why I asked about sleeping in FlicScript.

      I've already done this functionality through IFTTT using their scripting capabilities and jumping through hoops triggering Tapo shortcuts for turning lights back off after a delay if they were off before changing the brightness, but I'm hoping to make it simpler and more efficient through FlicScript.

      The catch is that to adjust the brightness you need to turn the light on. So, if the light is already on, I can set the new brightness and that's that. But, if the light is off, it needs to be turned on to the new brightness and then turned back off so that when it's next turned on manually it will be at the desired brightness. To do this properly, I need to know if the light was currently on or off before adjusting the brightness so that it can be back in its previous state after the change is done. It's a little weird to have my lights turn on and off throughout the evening but not being blasted will full brightness lights later into the evening is nice.

      It would be amazing if it were possible to adjust the "remembered" brightness without turning the light on, but from what you described before it sounds like that's not possible even with this more direct access to the Matter devices. Or am I mistaken? I haven't had a chance to test that deeply yet. Would writeAttribute be able to adjust the brightness without turning a light on?

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

      @Emil Thank you so much, this is exactly the info I was hoping for! I've already done a proof of concept and it was so awesome to be able to toggle my Matter light via script, it's gonna be so much fun to control my house this way!

      About getting the current status, the only way is via the asynchronous subscription? There is no synchronous way to just directly query the current status? If so, I can build a synchronous function around a subscription that is awaited and then canceled when the value is retrieved. Just want to be sure that is the best option before I move forward with that.

      Also, out of curiosity, what would the writeAttribute method be used for?

      posted in Flic Hub SDK
      pico
      pico
    • RE: Sleeping in FlicScript

      @Emil Thank you! This is exactly the confirmation I needed to get started with my project! It's so cool to be able to script Matter devices!

      posted in Flic Hub SDK
      pico
      pico