What is wrong with this code ? ( opening screen when too hot)

  • alias: ‘Test2’
    trigger:
    • above: ‘16’
      entity_id: sensor.fibaro_system_fgms001zw5_motion_sensor_temperature
      platform: numeric_state
      action:
    • service: cover.set_cover_position
      data:
      id: ‘1520594767510’
      position: 0

i get :

WARNING (MainThread) [homeassistant.core] Unable to find service cover/set_cover_position
ERROR (MainThread) [homeassistant.core] Invalid service data for cover.set_cover_position: extra keys not allowed @ data[‘id’]. Got ‘1520594767510’

Code indentation is f*cked, so ‚id‘ became an property of the data-section. Also, unless you want to open all covers, there should be an entity_id in that data section.

Please use the code formatting feature of this forum‘s editor for further analysis.

- alias: 'Test2’
  trigger:
    - above: '16’
      entity_id: sensor.fibaro_system_fgms001zw5_motion_sensor_temperature
      platform: numeric_state
  action:
    - service: cover.open_cover
  id: '1520594767510’

I’m sorry I messed it up.
What you said about the entity_id… Isn’t that the id in the action that makes that the right screen is closed?

Yeah, but it‘s missing in your action part. There‘s only ‚id‘, but that‘s the internal, autogenerated id of this automation.

this is my code now

- alias: 'Test1'
  trigger:
  - above: '16'
    entity_id: sensor.fibaro_system_fgms001zw5_motion_sensor_temperature
    platform: numeric_state
  action:
  - service: cover.close_cover
    data:
    entity_id: cover.level

I get an error on the service
“Unable to find service cover/close_cover”

but I just saw that my screens are “dead”, that’s the problem I think

cover.close_cover is available for me (see screenshot), but maybe it depends on the type of hardware. You could stick with cover.set_position if that is working for you.

- service: cover.set_cover_position
  data:
    entity_id: cover.level
    position: 0

the strange thing is that cover.close_cover is also available for me…
But I think it’s because they are in “dead” modus …

In your code the indentation of entity_id inside data is not correct. Either use

- service: cover.close_cover
  entity_id: cover.level

or

- service:cover.close_cover
  data:
    entity_id: cover.level

Frankly speaking, your automation is quite primitive as it contains no templates or complex condition rules. Why not use the Automation Editor of you Home Assistant instance to model it in a graphical manner?

My personal opionion: It’s totally stupid to express logical coherence by indentation, but some people still think it’s a good idea. Actually, I am considering using JSON inside YAML, as YAML is a superset of JSON and allows embedding JSON.

{
 "alias":"Test2",
 "trigger": [{
   "above": 16,
   "entity_id": "sensor.fibaro_system_fgms001zw5_motion_sensor_temperature",
   "platform": "numeric_state"
  }],
  "action": [{
   "service": "cover.open_cover",
   "entity_id": "cover.cover_level"
  }]
}

Easy to read, easy to validate, indentation-independent semantics.

It’s just because I am a totaly newbie and I am not good at programming :slight_smile: