This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
Official HomeyScript
Comments
Getting the scripts to work is not the hardest part. I use the Net Scan app and made this script to get a list of online devices. I put all my devices in a zone called Network.
However I still get double output and I want to use this output in a flow, but I have no idea how to do this.
Maybe fill a Global Tag, still trying to work that out.
Listing each flow and the content of the flow: devices, setting, formulas etc - kind of manual back up in case you have to reconstruct everything... Or just would like to get some kind of overview of where you used a specific variable or so...
somebody have an idea how I could set a Z-Wave device configuration parameter?
I can read it with
Thanks!
For example:
The only way that would be possible is by using the app api. If Email Sender has an API, otherwise it needs a PR or you need to mail the dev
I adapted this example but the (Flow) tags don't get listed here. Do I have to get them into a variable first with say Better Logic ?
but setting the token from a trigger to a variable and execute te HomeyScript with above example the next second should work as workaround.
If not...then I can get the value of the variable using the token example script but how would I then update it with a new value .. and hence update the variable value ? I don''t see a setToken method.
I'm trying to do a bit of string manipulation in a script to extract a substring of a tag value. Are there any other apps that might help with this ? String manipulation seems totally absent.
Kevin
https://runkit.com/docs/endpoint
JavaScript has the setTimeout and setInterval command, but HomeyScript doesn't seem to recognize it.
It works, but I'd like to accomplish more. The script uses Better Logic and relies on apiPut(), but I want it to be more versatile.
How can I trigger programmatic flows? I can find the flows, but have no clue how to trigger them.
How do I change the value of Logic variables? Same story, I can find the tokens, but cannot change their values.
The API documentation doesn't quite match with the objects I've observed. Any pointers to other docs? Did I miss something?
Thanks in advance. I'd appreciate your feedback.
Is there anyone who has some Idea how to add a thirdparty library (like Mobus) to Homey?
Or is that just impossible?
If i have a device with ID: '123abc'.
How do i fetch the onoff state of this device in homey script.
if you just want to read the onoff state, you can do it this way:
I have a virtual device that is on if my alarm is triggered. This script will turn all my hue bulbs red and keep blinking them once every 1500ms, until the alarm is not triggered anymore.
I am not a programmer, and never have written java before, so this is not a good structure. And I am sure the script could be written in a much simpler matter. But I'm not coder enough to do that my self. Most of the code above is just copy/pasted and edited.
I have almost 50 hue bulbs at home, this script is not working perfect for that amount of bulbs. It works very well when i test it with just a few ones instead. I think the problem is that it takes some time for the lopp to go through all the 50 lights and turn then on/off individually on every loop. It would probably be better if I could write the script to turn on/off ALL lights in one command, and not do it individually for every single one. But don't know if that is possible.
If you want to use this script your self, i think the only thing you'd have to adjust is the id on line 27, so the script can check if your alarm is triggered or not.
Unfortunately, there, as far as i know, no way to set all lights on or off at ones.
But I have modified your script a little:
First you can see that i set the lights ON at start. Second: i have recoded your delayedLoop. It now switches of the lights when the alarm trigger goes in the 'off' state and the it will leave the loop.
I have not tested the modification but i think it should work
I saw the promise and subscribe functions in the documentation for the API, but did never understand how to use them (and to be honest, even in the code you wrote, I do not understand fully how it works, but understand what it does).
I've been at the stove all day, so didn't have time to do more than paste and test, and it seems to work fine. Just some small timing quirks, all lights did not turn off after the loop stops, and some times some lights does not have time to turn off between the loops, this is most likely due to the amount of bulbs I have. Will test more intensively when time comes by.
Two follow up question, how can I trigger a flow from the script (a flow with "this flow started" in "when", or with a bitflip)? I have a flow that resets the lights to the standard scenes depending on daytime/presence/etc.
Is there a smart way to filter out the bulbs that is not capable of color (have 6 lights that are white only)
similar to this part of the script, "if(device.class != 'light') return;"
the differense between the whites and the color bulbs
White just have: capabilitiesOptions: { onoff: {}, dim: [Object] }
color have: { onoff: {}, dim: [Object], light_hue: [Object], light_saturation: [Object], light_temperature: [Object], light_mode: {} }
You can trigger a flow this way:
to filter out bulbs that are color, you can use the device.capabilities object
methode 1: device.capabilities.light_mode.values is an array of objects. One of the objects should have an id = 'color'
methode 2: you can test if the device.capabilities object has an light_hue and/or light_saturation object and that object should have an propertie setable=true
//Edit
This Works
let devices = await Homey.devices.getDevices();
return Object.values(devices).some(device => {
if(device.zone.name.substr(device.zone.name.length - 5) != "(Lys)" ) return false;
if(!device.state.onoff) return false;
console.log(device.name);
return true;
});