Shelly Cloud - new Component? How to implement it? API is available

Have you checked the other settings on the shelly. Under timers for example check the auto on/off settings. Mine are all set to 0.

On another matter, the auto off on my shelly 1 only turns off after X time if I use the physical switch. If I use Mqtt to turn it on then it stays on.

I have clean session on, it should ignore retained messages then when it connects. I use QoS 1

Did you do a factory reset?

So yours does not turn off on HA restart? It’s odd, as the HA service should not interfere with a MQTT based entity. I’m debugging from a Windows 10 laptop so I don’t directly have access to mosquitto sub tools.

I’ve not had any issues. Expected to want to put tasmota on straight away but got it working with the settings I described. I can confirm it stays on when I restart ha. I am using a shelly 1 though. Not tried a 2 yet.

Are you using the MQTT add-on for Hass.io?

I am now but I do remember it working ok with the built in server too. I have found that the add on speeds up hassio, particularly at boot up as I have added more Mqtt devices

I’ve just spun up a Docker container with MQTT and connected one Shelly to it. Restarting that instance does not turn off the light but it does with the Hassio MQTT add-on. I also had an issue with the Monitor presence detection where the two Pi’s I had would flood the MQTT add-on with connect/disconnect messages and essentially make all my MQTT devices unusable. It did not appear to behave the same with a Docker instance on my NAS.

I might try flicking everything back to my Docker instance and see how I go.

Found my problem!! Something funky going on with MQTT Light. I have two of the Shelly relays configured as lights. Doesn’t matter whether I have MQTT on/off on the Shelly, clean session on/off, retain true/false on HA, none of it makes a blind bit of difference.

If I restart HA, it sends a command ‘off’ to the Shelly command topic which I’ve tracked using MQTT.fx. however, one of the Shelly relays is configured to control a ceiling fan as a MQTT switch as this does not turn off on HA restart (same device as one of the lights that does turn off).

Some for some reason, HA sends an off command on restart to the command topic of the Shelly lights.

light:
  - platform: mqtt
    name: "Kitchen Lights"
    state_topic: "shellies/shellyswitch-9F6008/relay/1"
    command_topic: "shellies/shellyswitch-9F6008/relay/1/command"
    qos: 2
    payload_on: "on"
    payload_off: "off"
    retain: false
    optimistic: false

switch:
  - platform: mqtt
    name: "Family Room Fan"
    state_topic: "shellies/shellyswitch-9F6008/relay/0"
    command_topic: "shellies/shellyswitch-9F6008/relay/0/command"
    qos: 2
    payload_on: "on"
    payload_off: "off"
    retain: false

Thanks for the update on this, all my lights are configured as switches so i never noticed this.

Have you figured out how the lwt message works or should be configured for the shelly?

@Crhass Haven’t played with that yet. Focused on keeping the lights going at the moment. I want the relays in HA as lights so I can use all lights off command in Lovelace and UI shows if any lights are on. I know I can do it with a template light as I’ve done with my Xaiomi switches that are controlling lights but I was hopeful of being able to bring them straight into HA as lights. Rob (?) from TheHookup is aware of my problem so I’m waiting to see if he has an answers. He posted a video today of configuring the Shellys in HA using MQTT.

Did you try uninstall and reinstall mqtt hass.io add-on?

Moved to external broker, same problem. Only happens when Shelly relay configured as MQTT light.

By the looks of the API docs both Shelly1 and 2 supports toggle. Have a look at the btn_type option http://shelly-api-docs.shelly.cloud/#shelly-switch-settings-relay-index.

This is my config running with a shelly1 as a light switch and a shelly2 as a roller shutter.
Enable MQTT on your shelly’s, and configure your mqtt broker (I’m using mosquitto in the same PI I’m running HA).

lights.yaml - For light switch

  - platform: mqtt
    name: "Light Sofa"
    state_topic: "shellies/shelly1-XXXXXX/relay/0"
    command_topic: "shellies/shelly1-XXXXXX/relay/0/command"
    qos: 2
    payload_on: "on"
    payload_off: "off"
    retain: false
    optimistic: false

**covers.yaml ** - For roller shutter

 - platform: mqtt
    name: "Living Room roller"
    state_topic: "shellies/shellyswitch-XXXXXX/roller/0"    # Returns open,close while in motion, stop when not moving
    command_topic: "shellies/shellyswitch-XXXXXX/roller/0/command"  # Accepts open, close, stop
    payload_open: "open"
    payload_close: "close"
    payload_stop: "stop"
    state_open: "open"
    state_closed: "close"
    retain: false
    optimistic: false
    qos: 2

**sensors.yaml ** - For roller shutter power consumption

  - platform: mqtt
    state_topic : "shellies/shellyswitch-32BF3D/relay/power"
    unit_of_measurement: "W"
    name: "Living room shutter consumption"

Hope it helps :slight_smile:

1 Like

@ cinzas
**covers.yaml ** - For roller shutter do not work for me. commands will never come to the device.

Theese commands are working, but the buttons (up, stop, down) will not be updated.

platform: mqtt
state_topic: "shellies/shellyswitch-5B2502/roller/0"
command_topic: "shellies/shellyswitch-5B2502/roller/0/command"
name: "Rollladen Office"
qos: 2
retain: false
optimistic: false
payload_open: "open"
payload_close: "close"
payload_stop: "stop"
open_cover:
  - service: mqtt.publish
    data:
      topic: 'shellies/shellyswitch-5B2446/roller/0/command'
      payload: 'open'
close_cover:
  - service: mqtt.publish
    data:
      topic: 'shellies/shellyswitch-5B2446/roller/0/command'
      payload: 'close'
stop_cover:
  - service: mqtt.publish
    data:
      topic: 'shellies/shellyswitch-5B2446/roller/0/command'
      payload: 'stop'

availability_topic do also not work, allready saved as Will Topic / Will Message on the device shellyswitch-5B2446.

availability_topic: "shellies/shellyswitch-5B2446/LWT"

How can I fix this?

That’s strange.

I don’t need the close_cover and stop_cover.
Are you using mosquitto? Can you run

# mosquitto_sub -v -h 127.0.0.1 -p 1883 -t '#'

And listen to what is happening in the broker
My buttons work and they reflect what I manually do, because the shelly switch send to the broker what is happening in the switch

thanks cinzas, mosquitto_sub works well.
Use a lot of other devices and all works.

switches and covers

mqtt sensors

When I test the shellies/shellyswitch-XXXXXX/roller/0/command with node-red, the commands will work. Only when I use your covers.yaml nothing happens.

I use Home Assistant 0.82.0

I can see a lot of warning when I use the settings:

- platform: mqtt
  state_topic: "shellies/shellyswitch-5B2502/roller/0"
  command_topic: "shellies/shellyswitch-5B2502/roller/0/command"
  name: "Rollladen Office"
  qos: 2
  retain: false
  optimistic: true
  payload_open: "open"
  payload_close: "close"
  payload_stop: "stop"
  open_cover:
    - service: mqtt.publish
      data:
        topic: 'shellies/shellyswitch-5B2446/roller/0/command'
        payload: 'open'
  close_cover:
    - service: mqtt.publish
      data:
        topic: 'shellies/shellyswitch-5B2446/roller/0/command'
        payload: 'close'
  stop_cover:
    - service: mqtt.publish
      data:
        topic: 'shellies/shellyswitch-5B2446/roller/0/command'
        payload: 'stop'

Messages

Commands open, close, stop will work. But the buttons will not reflect when I manually do.
What I doing wrong ???

is it possible to add the ultrasound or magnetic sensor to the shelly 1 and use it as a garage door opener?
thanks

I used this and it works great - thank you.

Did you get it working?

@ ashscott

Negative.

The problem is that the Shelly2 always reports only the current status (close, open, stop). If the shutter is closed, then “close” is reported and at the end “stop”. Thereafter, always “stop” is reported.

With me it is so that when opening or closing the buttons are activated. The status “STOP” is not displayed.

I hope that the MQTT messages will be revised with a new firmware and more information will be provided. The way via REST is also limited, because there are not all status messages available.

Since I have no other firmware (Tasmota would be an alternative) to flash over OTA, I have to wait for the firmware to improve.