State and numeric_state not working for cover conditions

Good day all! I’m trying to update my conditions to use the state or numeric_state of the velux shade covers. The goal is to use whether the skylight shades are open or closed to dictate the brightness of the lights in the kitchen.

First, I tried using:

    - condition: numeric_state
      entity_id: "cover.velux_left"
      below: 51
    - condition: numeric_state
      entity_id: "cover.velux_right_2"
      below: 51  

It gave an error when executing:

Error: In ‘and’ (item 4 of 5): In ‘numeric_state’: In ‘numeric_state’ condition: entity cover.velux_left state ‘open’ cannot be processed as a number In ‘and’ (item 5 of 5): In ‘numeric_state’: In ‘numeric_state’ condition: entity cover.velux_right_2 state ‘open’ cannot be processed as a number

So, I tried as a state:

    - condition: state
      entity_id: "cover.velux_left"
      state: closed
    - condition: state
      entity_id: "cover.velux_right_2"
      state: closed 

Unfortunately, I get errors reloading the automation configuration:

2022-05-23 11:34:09 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [state] is an invalid option for [automation]. Check: automation->state. (See /config/configuration.yaml, line 9).

This is an example of an automation that I’m trying:

- id: '1899958999003'
  alias: Kitchen lights on with lots of cloud cover
  trigger:
    platform: state
    entity_id:
    - group.kitchen
    to: 'on'
  condition:
  - condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.openweathermap_cloud_coverage
      above: 49
    - condition: sun
      before: sunset
      before_offset: -01:30:01
    - condition: state
      entity_id: "cover.velux_left"
      state: open
    - condition: state
      entity_id: "cover.velux_right_2"
      state: open
  action:
    - parallel:
        - service: light.turn_on
          target:
            entity_id: light.kitchen_main_lights
          data:
            brightness_pct: 50
        - service: light.turn_on
          target:
            entity_id: light.kitchen_under_cabinet
          data:
            brightness_pct: 70
        - service: switch.turn_off
          target:
            entity_id: switch.kitchen_sink_light

Any advice is appreciated much.

For covers, the state is a text. The position you are after is in an attribute, named “current_position”.
So for position checks, a condition could look something like this:

  - condition: numeric_state
    entity_id: cover.dakscherm_links
    attribute: current_position
    above: '10'
    below: '20'

I do not use the text state for conditions, but I think the values should be in quotes.

1 Like

Ah, so something like this I suppose then for closed:

  - condition: state
    entity_id: "cover.velux_left"
    attribute: current_position
    above: '-1'
    below: '1'

And for open:

  - condition: state
    entity_id: "cover.velux_left"
    attribute: current_position
    above: '0'
    below: '101'

Am I off on that? I did it the way I did as I know some conditions freaked out if there wasn’t an above/below together while others seemed fine. Not sure why.

Well dang, I tried it out with the open version above and without the below variable.

“Invalid config for [automation]: [above] is an invalid option for [automation]. Check: automation->condition->0->conditions->3->above. (See /config/configuration.yaml, line 9).”

If you do not need above or below, you can leave it out completely, no need to use values below 0 or above 100. And I think you should check your indenting, I think it is too low for the lists, but I’m not sure When I’m in doubt I use the gui editor to help me out.
The condition I posted is right out of a working script, so that should be fine.

Copy, will knock that out in a bit and see what happens. Thank you.

You need to remove the quotes around the entity_id:

  - condition: state
    entity_id: cover.velux_left
    attribute: current_position
    above: -1
    below: 1

other than that I can’t see anything wrong with your conditions.

Copy. Thank you both. Things are not erring and now I need a crazy hot day and some rainy days to help test out the new conditions.