@pico right now that particular code only acts as a client.

Posts made by Emil
-
RE: Flic Hub LR as MQTT Broker?
-
RE: Flic Hub LR as MQTT Broker?
@pico I think this should be possible. You just need the javascript code that implements it. The underlying tcp/udp support we have should make it possible.
-
RE: Could not complete operation
@kerry-thacher I sent you instructions on 5 feb how to enable logging for Apple TV as well, privately. That is what james-2 is referring to I assume. However, you responded that you have never run Homekit on your AppleTV.
-
RE: Could not complete operation
@james-2 please file a case at https://flic.io/support and I will continue from there. Press "none of the above" when asked, in order to create an actual support ticket. Please include a link to this forum thread.
-
RE: Cross-Module Persistent Data Storage
@pico I get your point. Maybe we should add a global datastore as well...
Did you know by the way that Govee lights support Matter? That way you should be able to control them using their static node id, so that you don't need to keep track of the IP address.
-
RE: Flics / Hub will not add to alexa
Could you try to log out from the Flic app and then log in again, to see if it works better then?
-
RE: Pre ordered Duo - double charges
@james-2 No worries, I just saw that your question safely arrived to our support inbox. The support team handling the orders will be checking your case and reach back to you as soon as they have processed your issue.
-
RE: FlicScript Matter Examples
@pico You can adjust the brightness even when it is off, so that it will remember the configured brightness the next time it is turned on. Execute the command I wrote under "setting brightness", adjusting node id and level as you wish.
The "options" is a bit map with currently only having one defined bit "ExecuteIfOff": "If this bit is set, commands in this cluster are executed and potentially change the CurrentLevel attribute when the OnOff attribute of the On/Off cluster is FALSE".
So, if you change OptionsOverride to 0 in the command, the command will be discarded in case the light is off. But if you leave it as 1, then the brightness will be modified in case the light is off.
You cannot write to the CurrentLevel attribute directly using a raw write since it is read only. You need to use one of the commands to adjust the level.
-
RE: FlicScript Matter Examples
@picomitchell wrapping a subscription using await works fine. Just make sure you remember to cancel it when done. The data is cached by the hub so no extra round trip will be necessary to the device. Out of curiosity, what is your use case for that functionality instead of listening to event updates? You can save the latest value in some variable which would be accessible by the rest of the code.
Writing attributes is not that common to do in an automation setup, since most things can be done by sending commands, but often settings that are to be stored for some time are modelled as attributes that you write to.
-
RE: Flics / Hub will not add to alexa
@dajudge can you try to go in to the flic app and, without connecting to the hub, add a normal Internet request action targering https://api.flic.io, save the action and then try to execute it? Then tell me if you get any error message in a notification?
-
RE: Flics / Hub will not add to alexa
@dajudge The issue is that our hub is not linked to your flic user account in our database. You need to have internet on your phone active and then connect to the hub using the app. At that point it will link the hub to your flic user account.
-
RE: FlicScript Matter Examples
@picomitchell See the following.
At the top of your file, put
matter = require('matter');
.Turning on and off:
matter.sendCommand("5716184942583194821", 1, "On/Off", "On", {}, (error, response) => console.log(JSON.stringify(error) + ", " + JSON.stringify(response))); // Turn on matter.sendCommand("5716184942583194821", 1, "On/Off", "Off", {}, (error, response) => console.log(JSON.stringify(error) + ", " + JSON.stringify(response))); // Turn off matter.sendCommand("5716184942583194821", 1, "On/Off", "Toggle", {}, (error, response) => console.log(JSON.stringify(error) + ", " + JSON.stringify(response))); // Toggle
The above assumes the node id of the device you are controlling is 5716184942583194821 (which you get from the
getNodes()
function) and the On/Off cluster you want to control is located at endpoint 1. Most devices have all the relevant clusters positioned at endpoint 1, but if one device has several logical parts (like a lamp with multiple light sources), they would typically have one endpoint per light source. Also Matter bridges have many endpoints; each bridged device is exposed as one or multiple endpoints.The third parameter "On/Off" is the name of the cluster and the following parameter is the name of the command (contained within that cluster) that you want to execute. These three commands take no option fields in this case, so the fourth parameter is just an empty object
{}
. The last parameter is a callback, executed when the the remote device has delivered the response, possibly with some return fields.Setting brightness:
matter.sendCommand("5716184942583194821", 1, "Level Control", "MoveToLevel", {"Level": 110, "TransitionTime": 0, "OptionsMask": 1, "OptionsOverride": 1}, (error, response) => console.log(JSON.stringify(error) + ", " + JSON.stringify(response)));
The level you can set is typically in the range 1 (minimum) to 254 (maximum). Set
OptionsOverride
to 0 if you don't want the command to take effect in case the light is off (so that when you later turn it on, it would be at the same level it was before). You can also replace the command name to MoveToLevelWithOnOff to make sure the light turns on when you simply set brightness to something more than 1, in case it was off. The transition time is in the unit 10ths of a second.Setting color using hue/saturation:
matter.sendCommand("5716184942583194821", 1, "Color Control", "MoveToHueAndSaturation", {"Hue": 254, "Saturation": 254, "TransitionTime": 0, "OptionsMask": 1, "OptionsOverride": 1}, (error, response) => console.log(JSON.stringify(error) + ", " + JSON.stringify(response)));
Hue and Saturation fields are both from 0 to 254.
Setting color temperature:
matter.sendCommand("5716184942583194821", 1, "Color Control", "MoveToColorTemperature", {"ColorTemperatureMireds": 370, "TransitionTime": 0, "OptionsMask": 1, "OptionsOverride": 1}, (error, response) => console.log(JSON.stringify(error) + ", " + JSON.stringify(response)));
The color temperature is in "mireds" (https://en.wikipedia.org/wiki/Mired). The Tapo light bulb has a range from 153 (coldest) to 400 mireds (warmest).
You can use the "command" window in the hub sdk to experiment with various commands. I recommend you to also use the Matter Other action in the app to experiment with various options.
To monitor the state, you can use the subscription feature:
let subscription = matter.subscribe("5716184942583194821", [{endpointId: 1}]);
If you want to filter on a specific endpoint/cluster/attribute, you declare that in the options parameter (all those three are optional). It is an array so you can put multiple filter (the updated attribute must match at least one filter). For example,
[{endpointId: 1, clusterName: "Level Control", attributeName: "CurrentLevel"}]
will only match the brightness. For On/Off status, you would want[{endpointId: 1, clusterName: "On/Off", attributeName: "OnOff"}]
. The filter[{}]
will listen to everything (wildcard).You get updates by registering an event listener for the
update
event:subscription.on("update", function(d) { console.log("connected: " + d.connected); if (d.updates === undefined) return; console.log(JSON.stringify(d.updates)); });
Initially you will get an immediately delivered event containing the current status (assuming the device is connected). This is indicated by
d.initialProbe == true
. You will get an update every time the connectivity changes true/false. The attribute updates will contain something like{"1":{"Level Control":{"CurrentLevel":254}}}
where from out to in you have endpoint number, cluster name, attribute name, value. Multiple attributes will be reported at once if they are updated at the same time. To see the whole structure of a Matter device, I recommend you to set up a subscription for the wildcard filter and print the initial probe result to the console.You can call the
cancel()
method on the subscription to stop getting updates (which also releases the resources). -
RE: Sleeping in FlicScript
Using
setTimeout
orsetInterval
is the preferred way. That is effectively the same performance cost as having a script running waiting for a button press. As long as your script doesn't do anything (consuming cpu cycles), the only cost is some RAM for the process to be active, which is totally fine. Note that you should never have a busy loop though, since FlicScript is event based.Make sure you tick "Restart after crash" before starting, so that your script will be restarted also after the hub reboots, e.g. after a power cut or firmware update.
-
RE: Flics / Hub will not add to alexa
@dajudge For some reason the Hub has not been linked to your Flic user account in our backend system. Can you make sure the app on your phone has internet access at the moment you connect to the hub?
-
RE: FlicScript Matter Examples
@picomitchell What device type are you trying to control? If you tell me the command you want to send and which parameters, I can give you an example. You can use the Matter Other action in the Flic app to list all the different commands available and options.
-
RE: Will we ever be able to view the battery info?
@Rice-Eater probably not. It's very hard to draw any conclusions from a battery discharge curve the first 70% of the battery usage since the voltage will always be high during that time. It's only when the battery approaches its end of life that you can really notice that the voltage drops more and more. Also when the battery is stressed, like when the LED is on, the voltage temporarily drops even more. That's why we have chosen this approach to only show an icon when we estimate the battery is low.
Other more sophisticated devices such as smart phones use coulomb counting to accurately estimate battery life but we can only measure the voltage level.
That said, with the SDKs we offer we can still give you the actual battery voltage level in case you want to use that information.
-
RE: Flics / Hub will not add to alexa
Are you using this skill? https://www.amazon.com/Shortcut-Labs-AB-Flic/dp/B08WXGP16H
You need to log in with your Flic account in that skill.What is the serial number of your hub? Is it connected to the internet?
-
RE: Flic with Spotify Loses Authentication
Hi, we have found the issue causing this in the Hub Firmware and a fix will be included in the next firmware release.
-
RE: Will we ever be able to view the battery info?
@Rice-Eater The app will show a red low battery indicator when the voltage is low. The Flic 2 button will also show two short red LED blinks when pressed if the voltage is low.
-
RE: Matter devices showing offline
@buckyswider did you finish the pair device again or didn't you have to since you noticed it became online again?