so 4 windows, 4 triggers
if 1 triggers then the others are conditions.
with the 4 simple automations and 2 groups i proposed, probably a climate would be turned of twice at “the same time” but if it is off ha wont turn it off, so 1 off the actions is to much, but doing nothing.
no not 3 conditions.
no conditions at all in his case, because he just want to turn something off when a window opens.
less lines, doesnt make it better in all cases. readability (so you still know what you did there after 6 months) is always also important.
and if its just about lines, then this is 1 line,
{% if is_state('binary_sensor.aken_arvuti', 'on') and is_state('binary_sensor.aken_telekas', 'on') and is_state('binary_sensor.aken_magala', 'on')%}
but i could also put more stuff on 1 line
automation:
- alias: magala window open
trigger: {platform: state, entity_id: binary_sensor.aken_magala, to: on}
action: [{service: climate.turn_off},{data:{entity_id: climate_magala}}]
then the automation is also just 3 lines. 4 times, so in total 12 lines.
and my lines are shorter.
so the actual decision isnt how many lines, but how complicated you want to write stuff.
but its all depending of the view of the user.
combining 2 languages to 1 piece of code doesnt make it neat for me, and for certain not when in the end you have more characters.
for me it is more neat to have 4 lines like this:
trigger: {platform: state, entity_id: binary_sensor.aken_magala, to: on}
then a block like this:
data_template:
entity_id: >
{% if is_state('binary_sensor.aken_arvuti', 'on') and is_state('binary_sensor.aken_telekas', 'on') and is_state('binary_sensor.aken_magala', 'on')%}
group.kyte_2korrus
{% elif is_state('binary_sensor.aken_arvuti', 'on') and is_state('binary_sensor.aken_telekas', 'on') %}
group.kyte_2korrus1
{% elif is_state('binary_sensor.aken_telekas', 'on') %}
climate.elutuba
{% elif is_state('binary_sensor.aken_magala', 'on') %}
climate.magala
{% endif %}
right, mine too
it was even hard to write it down correct, but still that is what is done with the climate situation
and that is why a lot off people struggle so much
Yeah, I think it’s because we all see the problem from a different perspective, which is probably why you’re good with python and I really really really struggle with it.
in general i see a whole lot of people trying to combine things to a big problem.
and in my experience it is always the best way to splitt things up.
in science they splitt everything up to the smallest possible building bricks.
and use a few bricks together to create new bricks.
here you see people who have 10 automations and they want to create 1 from it.
just the other way around.
to built a wall you create 1 stone after another and then glue them together with cement.
if you take all the clay you need for the bricks and the cement together and trow it on 1 pile and try to build a wall from it you will never succeed.
but i am glad that @typeonegative figured it out, so its not that big of a problem that i am talking a bit phylosifical here
(still puzzles me why @typeonegative did ask my advise here, because i havent shown a lot off knowledge about this kind of things and other do)
then i only can say: thank you
but like all other people i can only be smart if i know how to use the tools
and there are others here that use this kind of tools way better then me.
I know i’m late to the party but it looks like you are just trying to turn off what is on.
This chunk of code should work better for expansion in the future if you add more of these devices. Your current solution would be a pain to manage if you add 1 more switch/climate device. So to clarify, It’s no better than the solutions you already have but it would be better for expansion because you just add to the sensor list and climate list.
entity_id: >
{% set sensors = [ 'binary_sensor.aken_arvuti', 'binary_sensor.aken_telekas', 'binary_sensor.aken_magala' ] %}
{% set climates = ['climate.elutuba', 'climate.trepp', 'climate.magala' ] %}
{%- for sensor in sensors if is_state(sensor, 'on') %}
{{- climates[sensors.index(sesnor)] }},
{% endfor %}