home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.79k stars 30.49k forks source link

Automation with 2 not dont work #47485

Closed nelsonamen closed 3 years ago

nelsonamen commented 3 years ago

The problem

Automation with 2 not don't work

What is version of Home Assistant Core has the issue?

2021.3.1

What was the last working version of Home Assistant Core?

2021.3.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Example YAML snippet

1

# Put your YAML below this line
 alias: Bem-vindo Alexa
description: ''
trigger:
  - platform: state
    entity_id: group.humanos
    to: 'on'
condition: []
action:
  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.door_window_sensor_any
        to: 'on'
    timeout: '00:10:00'
    continue_on_timeout: false
  - choose:
      - conditions:
          - condition: not
            conditions:
              - condition: state
                entity_id: device_tracker.susana
                state: home
        sequence:
          - service: notify.alexa_media
            data:
              data:
                type: tts
              message: 'Hello Nelson, Welcome Home!'
              target:
                - media_player.nelson_s_echo
      - conditions:
          - condition: not
            conditions:
              - condition: state
                entity_id: device_tracker.nelson
                state: home
        sequence:
          - service: notify.alexa_media
            data:
              data:
                type: tts
              message: 'Hello Susana, Welcome Home!'
              target:
                - media_player.nelson_s_echo
    default:
      - service: notify.alexa_media
        data:
          data:
            type: tts
          message: 'Hello Nelson and Susana, Welcome Home!'
          target:
            - media_player.nelson_s_echo
mode: single

## 2

alias: Plex Control
description: 'Controlar Luzes '
trigger:
  - platform: state
    entity_id: media_player.plex_plex_for_samsung_tv_2018
    to: idle
  - platform: state
    entity_id: media_player.plex_plex_for_samsung_tv_2018
    to: paused
  - platform: state
    entity_id: media_player.plex_plex_for_samsung_tv_2018
    to: playing
  - platform: state
    entity_id: sensor.samsung_source
    to: Plex
condition:
  - condition: not
    conditions:
      - condition: state
        entity_id: media_player.plex_plex_for_samsung_tv_2018
        attribute: media_content_type
        state: tvshow
      - condition: not
        conditions:
          - condition: state
            entity_id: media_player.plex_plex_for_samsung_tv_2018
            attribute: media_content_type
            state: video
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: media_player.plex_plex_for_samsung_tv_2018
            state: idle
          - condition: state
            entity_id: sun.sun
            state: below_horizon
        sequence:
          - service: switch.turn_on
            data: {}
            entity_id: switch.sonoff_1000686bc0
      - conditions:
          - condition: state
            entity_id: media_player.plex_plex_for_samsung_tv_2018
            state: paused
          - condition: state
            entity_id: sun.sun
            state: below_horizon
        sequence:
          - service: switch.turn_on
            data: {}
            entity_id: switch.sonoff_1000686bc0
      - conditions:
          - condition: state
            entity_id: media_player.plex_plex_for_samsung_tv_2018
            state: playing
        sequence:
          - service: homeassistant.turn_off
            data: {}
            entity_id: group.estadoluzes
      - conditions:
          - condition: state
            entity_id: sensor.samsung_source
            state: Plex
        sequence:
          - service: switch.turn_on
            data: {}
            entity_id: switch.amenserver
    default: []
mode: single

Anything in the logs that might be useful for us?

# Put your logs below this line

Automation with 2 not dont work i use With plex condition not tvshow and not video and dont work

frenck commented 3 years ago

Could you provide a not working example YAML script that doesn't work? Any errors logged? What should I do to reproduce your issue?

nelsonamen commented 3 years ago

ok

nelsonamen commented 3 years ago

Logger: homeassistant.components.automation Source: components/automation/init.py:636 Integration: Automação (documentation, issues) First occurred: 5 de março de 2021 22:08:25 (4 occurrences) Last logged: 0:59:02

Error evaluating condition in 'Plex Control': In 'condition': In 'not' (item 1 of 2): In 'state': In 'state' condition: attribute 'media_content_type' (of entity media_player.plex_plex_for_samsung_tv_2018) does not exist In 'not' (item 2 of 2): In 'not': In 'state': In 'state' condition: attribute 'media_content_type' (of entity media_player.plex_plex_for_samsung_tv_2018) does not exist

frenck commented 3 years ago

You figured it out @nelsonamen ?

nelsonamen commented 3 years ago

Yes, in the first the code is incorrect trigger:

Must be to: home.....

In the 2 i do in different way

alias: Plex Control description: 'Controlar Luzes ' trigger:

And now works!! 😁😁

nelsonamen commented 3 years ago

Logger: homeassistant.components.automation Source: components/automation/init.py:636 Integration: Automação (documentation, issues) First occurred: 5 de março de 2021 22:08:25 (4 occurrences) Last logged: 0:59:02

Error evaluating condition in 'Plex Control': In 'condition': In 'not' (item 1 of 2): In 'state': In 'state' condition: attribute 'media_content_type' (of entity media_player.plex_plex_for_samsung_tv_2018) does not exist In 'not' (item 2 of 2): In 'not': In 'state': In 'state' condition: attribute 'media_content_type' (of entity media_player.plex_plex_for_samsung_tv_2018) does not exist

But the in the plex the attribute: media_content_type only works if plex is playing