Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95528

Problem with condition within action - odd behaviour

$
0
0

@daern wrote:

I have a recent project - a connected doorbell sending in to an RPi hosted HA instance via MQTT. I use it to trigger a broadcast on one (or more) Google Homes and I am very happy with this solution which works well. I now want to add an extra enhancement: when the doorbell is pressed, turning the outside light (Tuya wifi switch) on for 3 minutes, but only if it’s dark. And this is where the problem starts.

When it’s dark, the rule works pretty well (although I do sometimes get an on -> off -> on from the light before it stabilises for the required 3 minutes). The problem is that when it’s light, the light is still being turned on and then off after perhaps 1 second, but weirdly, the notification rules (put in their for fault-finding) are not being triggered. I’m new to HA but I think I’m doing it right. I’ve tried a couple of different (valid) syntaxes for the condition command, but none work correctly.

Any suggestions as to what I’m doing wrong here? The exact automation config I’m using is posted below, with only the identifying URLs and entity IDs changed:

- id: '349873443422'
  alias: Front Doorbell
  description: ''
  trigger:
    payload: front_door_ring
    platform: mqtt
    topic: doorbell
  condition: []
  action:
    - service: media_player.volume_mute
      data:
        entity_id: media_player.broadcast_speakers
        is_volume_muted: false
    - service: media_player.volume_set
      data:
        entity_id: media_player.broadcast_speakers
        volume_level: 0.5
    - service: media_player.play_media
      data:
        entity_id: media_player.broadcast_speakers
        media_content_id: http://www.myserver.com/doorbell-2.mp3
        media_content_type: 'music'
    - condition: and
      conditions:
        - condition: state
          entity_id: sun.sun
          state: 'below_horizon'
    - service: persistent_notification.create
      data:
        message: "Sun down - light on"
        title: "Test"
    - service: switch.turn_on
      entity_id: switch.xxxyyy
    - delay:
        seconds: 180
    - service: switch.turn_off
      entity_id: switch.xxxyyy
    - service: persistent_notification.create
      data:
        message: "Sun down - light off"
        title: "Test"

So, to clarify, when the sun is “above_horizon” (i.e. it’s daytime), the light turns on and then off immediately, but the notifications don’t fire. When the sun is “below_horizon”, the light turns on for 15 seconds and then turns off and the notifications fire accordingly.

Any suggestions or ideas here?

Posts: 8

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95528

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>