@Crumpy10 wrote:
Hello everyone, I am a little bit stuck on some basics. Go easy on me, I am not a code guru and learning this stuff comes very hard to me!
So I have a system that I am trying to convert over from OpenHab to HA. I am stuck on a rule which I believe should be a script in HA?
At the moment I am trying to figure out a switching script that when I ask Alexa to turn the office lights on the system decides to switch a relay in a sonoff on or off to complete the task.
My lights are wired like a 2 way lighting circuit with conventional switch at one end and a Sonoff 4 channel SPDT relay at the other.I have looked through the docs and the Jinja docs to try and figure out the conversion of my original working code in Openhab to a script in HA.
Here is my original working code in OH-:rule "Sonoff4ch_1Channel1 Toggle" when Item Sonoff4ch_1Channel1 received command then if (receivedCommand != Sonoff4ch_1Channel1.state) { // only if new request does not match actual current state // then we need to toggle the relay state if (Sonoff_relay1.state == OFF) { Sonoff_relay1.sendCommand(ON) } else { Sonoff_relay1.sendCommand(OFF) } } // else already in requested state end
and here is my effort to convert it…
#Sonoff 4 channel Alexa 2way lighting toggle script file script: control_lights_toggling: sequence: # This is Home Assistant Script Syntax - {% if input_boolean.2way_toggle != binary_sensor.office_lights %} # Only continue if new request does not match physical state of light {% if office_lights == off %} # Now we need to toggle the relay state service: light.turn_on entity_id: light.office_lights {% else %} service: light.turn_off entity_id: light.office_lights
When I try to place the script in HA the configurator throws me this error-:
missed comma between flow collection entries at line 16, column 6: - {% if input_boolean.2way_toggle ! ... ^
Would someone mind pointing out a way forward? I have looked and dont understand what comma is missing, I have looked at loads of examples and cant figure it out…
Cheers
Simon
Posts: 6
Participants: 2