Flic Home

    Community

    • Login
    • Search
    • Popular
    • Users

    New Flic Twist features for the Hub SDK

    Flic Hub SDK
    7
    23
    2377
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Emil
      Emil FlicTeam last edited by Emil

      We are today announcing a Beta release of some new features in the Hub SDK that can be used together with Flic Twist.

      In order to seamlessly continue to work with the rest of your smart home devices that you might have assigned to other triggers on the Flic Twist, we introduce the concept of Virtual Devices. A Virtual Device is handled by the Flic Hub firmware just like any other supported real device, but its functionality is implemented by the user in the Hub SDK, typically by writing some kind of bridge software that sends commands and receives update events over the LAN to/from the real device. If for example the brightness of a (real) light is changed by some external means, it is possible to tell the Flic Hub firmware from javascript about the new brightness level, which the hub then forwards to the Flic Twist, so that the LED status can update accordingly. That way when you twist it, it will start from the correct position.

      We are also adding a "message" action that can be used to send arbitrary strings to your scripts whenever the action is triggered. The intended use case is to be able to trigger custom code also for Push/Double Push in the Selector feature or perform some action when a specific point is reached in Advanced Dimming or Scene Blender.

      The virtual devices can be created in the Flic App and be set to be controlled by a Flic Twist as follows:

      IMG_9799.png

      IMG_9797.png

      Using this piece of code, updates are received in your javascript code after configuring a virtual device to be triggered in the Flic App for a specific Flic Twist:

      const flicapp = require("flicapp");
      
      flicapp.on("virtualDeviceUpdate", (metaData, values) => {
          // The values object can contain hue, saturation, brightness, colorTemperature, volume, position (for blinds)
          console.log(`Twist ${metaData.buttonId} updated virtual device ${metaData.virtualDeviceId} of type ${metaData.dimmableType} with these values: ${JSON.stringify(values)}`);
      });
      

      When a device is modified externally, we use this function to inform the system of the change:

      flicapp.virtualDeviceUpdateState(dimmableType, virtualDeviceId, values);
      

      The dimmableType can be either "Light", "Speaker" or "Blind". The values is an object containing at least one of the fields mentioned above that is appropriate for the corresponding dimmableType. For example:

      flicapp.virtualDeviceUpdateState("Light", "my_ceiling_light", {hue: 0.6, saturation: 0.7, brightness: 0.8});
      

      The values themselves are always floating point numbers between 0 and 1.

      Configure an action message to be triggered by assigning the following action in the Flic app:

      IMG_9798.png

      The action messages are easy to receive, just register a listener as follows:

      flicapp.on("actionMessage", message => console.log(`Got a message: ${message}`));
      

      We'd love to hear your feedback!

      sgemmen andreas.lorentsen 3 Replies Last reply Reply Quote 3
      • Emil
        Emil FlicTeam @hmmwhatsthisdo last edited by

        @hmmwhatsthisdo Could you elaborate what you did when you unregistered the hub from device manager? There should be a red trash can icon which will delete the hub. Make sure you are not just removing it from a group or similar but remove it completely.

        1 Reply Last reply Reply Quote 0
        • hmmwhatsthisdo
          hmmwhatsthisdo @hmmwhatsthisdo last edited by

          @Emil Even after unregistering the Hub from Device Manager, triggering an update from 4.3.9 (from DM) reinstalls version 4.2.14. Trying to update the firmware again yields the same "Firmware already latest version" message.

          Emil 1 Reply Last reply Reply Quote 0
          • hmmwhatsthisdo
            hmmwhatsthisdo @Emil last edited by hmmwhatsthisdo

            @Emil Sure, I can try unregistering the hub from Device Manager again and see if that changes things.

            However, as I was mentioning earlier, I don't recall using Device Manager before this evening: My DM2 account was set up this evening, these are consumer (not corporate) devices, and I don't have anything in my email suggesting I had interacted with an earlier version of Device Manager in the past.

            It seems odd that the Hub was stuck on firmware version 4.2.14 even before registering with Device Manager.

            hmmwhatsthisdo 1 Reply Last reply Reply Quote 0
            • Emil
              Emil FlicTeam @hmmwhatsthisdo last edited by Emil

              @hmmwhatsthisdo Sorry, I was maybe too fast typing my reply or not clear enough. The hubs on the Device Manager path have slightly different firmware builds compared to firmwares for non-device manager. Therefore, the "latest stable" on Device Manager does not necessarily correspond to the same latest stable version for the normal consumer firmware as we require different testing for Device Manager hubs vs consumer hubs. The Device Manager firmwares might also lag a bit in regards to functionality compared to the consumer version.

              That said, I now see that the Twist features have yet not reached the firmware used for Device Manager hubs. I will escalate this issue and try to get it resolved ASAP. In the meantime I suggest that you deactivate Device Manager for this hub if you want to try out the feature.

              hmmwhatsthisdo 1 Reply Last reply Reply Quote 0
              • hmmwhatsthisdo
                hmmwhatsthisdo @hmmwhatsthisdo last edited by

                @Emil Picking 4.3.9 has at least gotten it to update that far. Setting the firmware config back to "latest stable" afterwards and triggering an upgrade in-app caused it to downgrade to 4.2.14 again, which was certainly unexpected.

                Emil 1 Reply Last reply Reply Quote 0
                • hmmwhatsthisdo
                  hmmwhatsthisdo @hmmwhatsthisdo last edited by

                  @Emil Reregistering the hub with Device Manager shows it is indeed configured for "latest stable":
                  feb1ee18-eb12-4d49-9758-c61591cf4203-image.png

                  Triggering a firmware update via the app while the Hub is in this state yields the same behavior ("Firmware already latest version")

                  Deleting and re-adding the Settings component (with the same config) has the same effect. I'd manually set it to 4.4.2, but the latest available in Device Manager is 4.3.9:
                  55fd1d26-117b-42f0-a982-c1e2e15b5ff8-image.png

                  hmmwhatsthisdo 1 Reply Last reply Reply Quote 0
                  • hmmwhatsthisdo
                    hmmwhatsthisdo @Emil last edited by hmmwhatsthisdo

                    @Emil Yeah, I had tried setting up Device Manager this evening to figure out options for managing modules via GitHub Actions. The firmware not updating past 4.2.14 has been occurring for longer than that. (I recall looking at the firmware update config options in DM and it did show "latest" though)

                    Let me re-register the device (interacting with the Hub via Device Manager caused my Twist to unpair, it seemed) and see if I can get it to a newer version.

                    hmmwhatsthisdo 1 Reply Last reply Reply Quote 0
                    • Emil
                      Emil FlicTeam @hmmwhatsthisdo last edited by

                      @hmmwhatsthisdo I see. That hub is registered with the Device Manager. With the Device Manager activated, you select yourself which firmware version you want it to have in the Device Manager portal. Try to select the latest version instead and then trigger a firmware update.

                      hmmwhatsthisdo 1 Reply Last reply Reply Quote 0
                      • hmmwhatsthisdo
                        hmmwhatsthisdo @Emil last edited by hmmwhatsthisdo

                        @Emil So, that's the weird thing. I hit the "Check for new firmware" button in-app, then the app suggests a new firmware version is available:
                        97cae519-b27c-455b-95b0-786801b6fb64-Screenshot_20250818-032828_Flic.png

                        When I hit the "Install Firmware" button, the app switches to a "Downloading" screen. Packet captures from the network my Flic Hub is on show it's opening an HTTPS connection to api.flic.io when this happens. A very small (<2 KiB encrypted) amount of data is exchanged, then the devices gracefully close the connection. The app then shows "Done" with "Firmware already latest version".

                        Is there a way to manually update firmware? The Hub's serial number is HBACG46-44223 if you'd like to check logs.

                        Emil 1 Reply Last reply Reply Quote 0
                        • Emil
                          Emil FlicTeam @hmmwhatsthisdo last edited by

                          @hmmwhatsthisdo-flic Can you please try to update the firmware to the latest version (should be 4.4.2)?

                          hmmwhatsthisdo 1 Reply Last reply Reply Quote 0
                          • hmmwhatsthisdo
                            hmmwhatsthisdo @Emil last edited by

                            @Emil Can you describe how to enable this feature now that it's available on Android?

                            I have version 3.13.1 of the Flic Android app, with Hub LR firmware version 4.2.14. When I open my Hub in the Flic app, then pick "Providers" from the ellipsis menu in the upper right, I don't see any Flic Hub Studio provider listed.

                            Emil 1 Reply Last reply Reply Quote 0
                            • rob.loosx
                              rob.loosx last edited by

                              Nice! It took me some time to get going with it, but I managed to create a script to control my Yamaha receiver volume & playback status using the Flic Twist and the Hub Studio.

                              Github: https://github.com/loosrob/Flic-Studio-Yamaha-control

                              1 Reply Last reply Reply Quote 0
                              • nick-flic
                                nick-flic last edited by

                                Really excellent to finally (!) have this released.

                                It's working well for me.

                                Thank you!

                                1 Reply Last reply Reply Quote 0
                                • Emil
                                  Emil FlicTeam @mosthated last edited by

                                  @mosthated The Android app with this functionality has now been released!

                                  hmmwhatsthisdo 1 Reply Last reply Reply Quote 0
                                  • mosthated
                                    mosthated @Emil last edited by

                                    @Emil

                                    I am debating on if it is even worth asking if there is an expected ETA on the Android release..

                                    Emil 1 Reply Last reply Reply Quote 0
                                    • Referenced by  Emil Emil 
                                    • Emil
                                      Emil FlicTeam @mosthated last edited by

                                      @mosthated Sorry forgot to mention that only the iOS app shows this provider right now. It will come later to Android.

                                      mosthated 1 Reply Last reply Reply Quote 0
                                      • mosthated
                                        mosthated last edited by mosthated

                                        How do I enable these features? I do not see anything related to virtual devices in the flic app, and it looks like the most recent update available is 3.12.3 from 02/11/2025. I don't see any options or settings, either in the play store, or in the app to enable any sort of beta access.

                                        My hub itself is showing v4.4.0. I don't see anything 'Studio' related showing up in providers, or in any settings.

                                        Emil 1 Reply Last reply Reply Quote 0
                                        • andreas.lorentsen
                                          andreas.lorentsen @Emil last edited by

                                          Here's a quick and dirty script I created to test volume control. Might be errors (even dragons) here, use at own risk. Maybe it's useful for someone sometime…I don't know.

                                          
                                          const buttonManager = require("buttons");
                                          const flicapp = require('flicapp');
                                          const net = require("net");
                                          const http = require("http");
                                          const client = 'INSERT IP ADRESS HERE'
                                          const port = 4710;
                                          
                                          let client = new net.Socket();
                                          var muteCommand = Buffer.from('set /devices/0/outputs/20/Mute/value/true \0', 'utf-8');
                                          var volumeCommand = Buffer.from('set /devices/0/outputs/20/CRMonitorLevelTapered/value/ ');
                                          
                                          flicapp.on("actionMessage", function(message) {
                                          		if(message == 'mute') {
                                          			sendToSocket(muteCommand);
                                          		} 
                                          		// handle more (else) cases here 
                                          });
                                          
                                          function sendToSocket(msg) {
                                          		client.connect(port, client, function() => {
                                                          client.write(msg);
                                          		})
                                          };
                                          
                                          flicapp.on("virtualDeviceUpdate", function(metaData, values) {
                                          	let virtualID = metaData.virtualDeviceId;
                                                  if(values.volume && values.volume != "") {
                                          	     sendToSocket(volumeCommand + values.volume + ' \0');
                                                  }
                                          	// console.log(metaData.virtualDeviceId);
                                          	// console.log(values.volume);
                                          });
                                          
                                          
                                          1 Reply Last reply Reply Quote 0
                                          • andreas.lorentsen
                                            andreas.lorentsen last edited by andreas.lorentsen

                                            Nice. I already got it up and running with a couple of custom volume controls. I use it in my home studio (remote controlling input/output volume on Universal Audio gear, controlling playback and recording when tracking vocals and drums etc), and one for my home surround system as well.

                                            Although…

                                            Can you PLEASE update the existing Spotify Connect "provider"/service to also include the volume (up, down, mute) endpoints as well as the existing ones?

                                            It would require next to no time and effort for you to configure, but it would probably make a world of difference for a lot of the "average" end users of your products.

                                            Think about it…the access token/authentication mechanisms are already there, the Spotify volume endpoints have been up and ready to serve since long before the dinosaurs, and it wouldn't require anything out of the ordinary to add it to your already working Spotify service provider.

                                            Don't get me wrong. The Hub SDK is really great now with the latest updates. I enjoy and love that level of flexibility and all the customization goodies, but it's clearly not for everyone - as the learning curve can be somewhat steep and in my opinion it's a total overkill if you have no prior programming skills or interest, but still want to make use of your Flic hub, Twist, Flic 2 button, Duo or whatever. Yay or nay? Oh and btw, great work. I don't just say that 😆

                                            (And please fix the Flic 2 Universal MIDI functionality, as it's useless at this point).

                                            🙏🏼🎠🤍

                                            Andreas

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post