Flic Home

    Community

    • Login
    • Search
    • Popular
    • Users
    1. Home
    2. pico
    • Profile
    • Following 0
    • Followers 0
    • Topics 7
    • Posts 19
    • Best 1
    • Controversial 0
    • Groups 0

    pico

    @pico

    1
    Reputation
    2
    Profile views
    19
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    pico Unfollow Follow

    Best posts made by 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

    Latest posts made by 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