I’ve automated my window shutters using a KaKu shutter control relay. To enable code re-use (we have 10 window shutters), I’m trying to create generic scripts to command the respective shutter to “open”, “close” or “partial open for ventilation”.
As part of this, I need to pass a parameter containing the device ID for the rolling shutter. I’m also passing 2 parameters with the time parameters for opening/closing.
I’ve implemented this using the “fields” construct in the script. This construct seems to work for the time parameters, but not for device_id parameter.
When I attempt to replace the hardcoded device ID with the variable “rolluik_id”, I cannot save the script, with errors similar to
I’ve read up on “Script Syntax”, “Dynamic Entity ID in Scripts” etc. to no avail. I cannot seem to understand why referencing a fields entry ‘rolluik_ventilatie_open_s’ works, but not a fields entry for ‘rolluik_id’.
Full script code below (fails to save after I replaced hardcoded ID in first sequence with field variable:
I’m using the “Run script” command in the overflow menu of the script editor, so I’d expect the value to be the default: switch.schakelaar_l_rolliuk_kantoor_links
Please consider marking my first post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
The script contains two sequential switch.turn_off service calls (separated by a delay). Is the need for the second one in case the first one fails to work?
Hi, no, this is a limitation / feature of the KaKu relays I’m using. The first “Off” command tells the shutter to open. The second “Off” command tells the shutter relay to stop moving.
In effect, the ventilation position is achieved by moving the shutter down (“On”) completely, then moving it up (“Off”) for a couple of seconds to slightly open the shutter.