#unknown action: mqtt.publish

33 messages · Page 1 of 1 (latest)

coral dune
#

Home assistant is complaining about one of my automations.
The automation "Garaget - MQTT Garage Door Status" (automation.mqtt_garage_door_status) has an unknown action: mqtt.publish.

This error prevents the automation from running correctly. Maybe this action is no longer available, or perhaps a typo caused it.

The automation in question is working and the action is:

action: mqtt.publish
data:
retain: true
payload: >-
{{ 'open' if states('binary_sensor.garagedorr_status') =='on' else 'closed'
}}
topic: home-assistant/garage/state

Am i missing something here?

short heraldBOT
rose vessel
#

Do you see the action there?

coral dune
#

My gut feeling is that MQTT gets ready later than the automations after a restart

shadow oasis
#

I use this service in so many automations, that is not the case

#

can you post the full automation? There's likely something else going on.

coral dune
#

ok

#
mode: single
triggers:
  - entity_id: binary_sensor.garagedorr_status
    trigger: state
actions:
  - action: mqtt.publish
    data:
      retain: true
      payload: >-
        {{ 'open' if states('binary_sensor.garagedorr_status') =='on' else
        'closed' }}      
      topic: home-assistant/garage/state````
rose vessel
#

I've seen it happen at times myself - automations loaded after MQTT

short heraldBOT
#

@coral dune To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

rose vessel
#

Haven't seen that for a while though

coral dune
#

Usually i just ignore it and it appears a month or two later

#

But it keeps comming back

shadow oasis
#

Your trigger triggers on any state change

#

that will be firing way more than it needs to, and that's likely your issue. It's firing before MQTT has started essentially

#

as a sidebar, what's the reason for this automation? Why put that data in MQTT?

coral dune
#

I'm starting to wonder why i did it too 🙂
Looking at the binary sensor

  - platform: template
    sensors:
      garage_door_status:
        friendly_name: 'Garage Door State'
        value_template: '{{ states.cover.garagedorr.state }}'
        icon_template: '{% if is_state("cover.garagedorr", "closed") %}mdi:garage{% else %}mdi:garage-open{% endif %}' ```

I have this in my config
```mqtt:

  cover:
    - command_topic: "shellies/garagedorr/relay/0/command"
      name: "Garagedörr"
      state_topic: "home-assistant/garage/state"
      availability_topic: "shellies/garagedorr/online"
      retain: false
      payload_open: "on"
      payload_close: "on"
      payload_stop: "on"
      state_open: "open"
      state_closed: "closed"
      state_opening: "opening"
      state_closing: "closing"
      payload_available: "true"
      payload_not_available: "false"
      optimistic: false ```
#

I have been running this for years so i forgot what i did but it is working great 🙂

shadow oasis
#

seems like you can do this with a single template cover

#

and nothing else

coral dune
#

Yes. this done based on examples many years ago and i have never bothered to change anything

shadow oasis
#

this should replace all you got

#
cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garagedörr"
        unique_id: garage_door
        value_template: "{{ is_state('binary_sensor.garagedorr_status', 'on') }}"
        open_cover:
          action: mqtt.publish
          data:
            topic: shellies/garagedorr/relay/0/command
            payload: "on"
        close_cover:
          action: mqtt.publish
          data:
            topic: shellies/garagedorr/relay/0/command
            payload: "on"
        stop_cover:
          action: mqtt.publish
          data:
            topic: shellies/garagedorr/relay/0/command
            payload: "on"
austere fog
#

is_states should be is_state

shadow oasis
#

i.e. no automation, no mqtt topic to store the state, no mqtt config, no template sensor config. Just a single Template Cover config.

coral dune
#

I also found this part

    - name: "Garagedörr Status"
      state_topic: "shellies/garagedorr/input/1"
      payload_on: '0'
      payload_off: '1'
      qos: 0
      device_class: door```
#

That is the switch that senses that the door is closed

shadow oasis
#

wait

#

so this can be done in a single MQTT entity then

#
mqtt:
  cover:
    - command_topic: "shellies/garagedorr/relay/0/command"
      name: "Garagedörr"
      device_class: garage
      state_topic: "shellies/garagedorr/input/1"
      availability_topic: "shellies/garagedorr/online"
      retain: false
      payload_open: "on"
      payload_close: "on"
      payload_stop: "on"
      state_open: "1"
      state_closed: "0"
      payload_available: "true"
      payload_not_available: "false"
      optimistic: false
#

@coral dune ^