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

Although mqtt is available I would love a component to be done. I want to keep Alexa functions and for that we need to have shelly with cloud access.

1 Like

Isn’t this it? https://gist.github.com/ispiropoulos/90a5f215e71f4dde635e3e3407fb5804 Custom component, but looks clean enough…my Shellys are in transit, so don’t know how well it works yet.

Hi
i have a shelly1, mqtt enable with the settings:
Clean Session on
Retain on
Max QoS 2

In Hass.io, in my config:
- platform: mqtt
name: “Shelly_Entrada_LuzPuerta”
state_topic: “shellies/shelly1-1CF901/relay/0”
command_topic: “shellies/shelly1-1CF901/relay/0/command”
qos: 1
payload_on: “on”
payload_off: “off”
retain: false
optimistic: false

the shelly is connected to a wall switch (to control a entry door light).

I see the switch in HA, but always off and if i try to turn on, it get back to off in a couple of seconds.

What could be wrong?

P.S. i had some sonoff, with espurna and tasmota, and full control with HA, the mqtt server is the hass.io default.

Thanks!

When that happens, it usually means that the Shelly is not available to HA.

Either off line or not configured correctly.

Get a copy of MQT Lens from the chrome app store and see if you can publish and subscribe to it using the topics in your config.

You can configure as many switches you like and they’ll show up and operate just how you are experiencing, without them physically existing. Chances are that’s what you’ve got going on.

Thanks @ashscott
I use MQTT.fx and i could subscribe to shellies/shelly1-1CF901/relay/0/command, but i’m new with mqtt and i doin’t know how to properly check (publish?) if the mqtt client of the shelly is working fine.

Will try with mqttlens when i get back home and post a screenshot :smiley:

@mrodrigues take a look here and here

1 Like

This is example of configuration with availibity for firmware 1.4.4:


You have to add autoaton rule to announce Shelies at HA start:

2 Likes

Ok, a little embarrasing, i just forgot to put the 1883 port to the ip in the shelly settings :smiley:
Works now!

Ok. thanks for that.

Just to clarify…

Do I need to add the “shellies/shellyswitch-5B2604/online” to the “Will Topic” in the Shelly configuration WebUI? Obviously I would change the detail of the center section to my own details (in my case “shellies/shelly1-32CADF/online”).

What then do I put in the “Will Message” section?

Could you post a screenshot of your webui showing that section of the config?

You have to use default settings like this:

shellies/shellyswitch-XXXXXX/online for Shelly2

Thanks!

Working good now.

My shelly 1 default topics are in the form of “shellies/shelly1-32CADF/relay/0”, “shellies/shelly1-32CADF/relay/0/command” and “shellies/shelly1-32CADF/online”. I had that part correct so it was the proper “Will Message” that was tripping me up.

Hi @Bieniu

what is unique_id for? Is it mandatory ?

Do I need to have retain to true? I prefer to have it to false.

Thanks

unigue_id isn’t mandatory. It will give you entity_registry support.

This is the entity of my Shelly1 with the changed name using the entity registry.
image
image

1 Like

where did you find the documentation for that being an option?

it’s not listed in the options on the component page for the MQTT switch. I haven’t really looked anywhere else aside from an unfruitful quick google search…

(and yes, I caught the mis-spelling and searched for “unique_id”)

I added this option and information about it to the documentation a few months ago. The documentation changed when the devices registry was added. You can use unique_id with all MQTT entities (switch/light/sensor/fan/binary_sensor/etc.)

do you have a link?

i looked in the docs for the mqtt switch and i didn’t see it there.

ok…

i understand (kind of…:slightly_smiling_face: ) about the need for a unique id to be included in the entity registry. I thought that was implemented through the integration of the component.

Based on these statements…

… what I was asking is where is it documented that “unique_id:” is a good configuration variable to use in the config of any mqtt device?

Mentioned here https://www.home-assistant.io/docs/mqtt/discovery/

I agree it isn’t immediately obvious and clear. It is a shame shelly doesn’t seem to provide mqtt discovery.

I’m writing a script that will automatically add Shelly switches to HA via discovery.