I’m switching from domoticz to Home Assistant. The scripting is totally different and I can’t find anywhere the commands that you can use and the syntax for it. I’m trying a simple if then else statement for practicing but don’t have any idea how to do it. this is the test script I created in the visual editor. What is want is to create also the off state of the switch to turn on the lamp. I hope there is a good website with syntax and available commands.
alias: New Automation
description: ''
trigger:
- platform: state
entity_id: input_boolean.test
for:
hours: 0
minutes: 0
seconds: 3
condition:
- condition: state
entity_id: input_boolean.test
state: 'on'
action:
- type: turn_off
device_id: 20b995602s83et23b564926e3bf776d97cd
entity_id: light.wand_lamp_1
domain: light
mode: single
Thanks, both work.
very difficult syntax though. any websites explaining the basic commands and syntax like , for next loop, do while and if then else, declaring variables and other basic stuff?
The first one in the post above is a good one, but you’ll need to review the docs for triggers and conditions to get the full picture. It’s not really a scripting language, though, and there are options like PyScript and AppDaemon if you’d prefer writing scripts and automations in Python instead.
I moved from domoticz some years agao . I missed Lua scripting. I was very uncomfotable with the bizare HA scripts . At first I used AppDaemon, then by using the templates switches , I began to understand the strange Jinja2 syntax. The developer tools are your friend. Look at the examples in the template and services tab.
After much persuasion , I have switched all my scripts to NodeRed . I thought it was like Blocky in domoticz . I was very wrong . It’s a simple elegant solution , perfectly adapted to the triggered nature of HA.
The learning curve is steep but woth it . Best of luck