Shelly issues

Dear all,

After having them laying around for quite a while, it was time to get a Shelly 1 and 2.5 working with HASSIO.
To do so, I added the Mosquitto add-on in HASSIO with the following configuration:

{
  "logins": [],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}

I created a user in the user configuration panel used by Mosquitto.
My configuration.yaml has the following line:

mqtt:
  broker: 192.168.0.62

The log of the Mosquitto add-on shows:

1576357458: New connection from 192.168.0.70 on port 1883.
[INFO] found mqtt on Home Assistant
1576357460: New client connected from 192.168.0.70 as mqtt-explorer-0fd101d3 (p2, c1, k60, u'mqtt').
1576357473: New connection from 192.168.0.64 on port 1883.
1576357473: New client connected from 192.168.0.64 as shelly1-E2D346 (p2, c1, k60, u'mqtt').
1576358161: New connection from 192.168.0.62 on port 1883.
1576358161: Socket error on client <unknown>, disconnecting.

I installed MQTT explorer to monitor the Shelly and Broker. When I change the Shelly relay via the web interface I can see the result in MQTT explorer. My conclusion, Shelly is working…

Now I’ve created 2 additional switches in configuration.yaml

switch:
  - platform: mqtt
    name: "terrace_outlet"
    command_topic: "shellies/shelly1-E2D346/relay/0/command"
    state_topic: "shellies/shelly1-E2D346/relay/0"
    payload_on: 'on'
    payload_off: 'off'
    retain: true
  - platform: rest
    name: "terrace_rest"
    scan_interval: 5
    resource: http://192.168.0.64/relay/0
    body_on: 'turn_on'
    body_off: 'turn_off'
    is_on_template: '{{ value_json == true }}'
    headers:
      Content-Type: application/x-www-form-urlencoded

One is via MQTT the other via RESTful, now the real issues…

Neither of the switches are shown in the developer tools’ state view??? Anyone got any idea here?
If I try to push the MQTT command via developer tools MQTT

shellies/shelly1-E2D346/relay/0/command

With payload: on the shelly does not respond. Anyone an idea here???

Basically I want the original firmware which works with RESTful and MQTT running in HASSIO. It took me already way too long to figure it out with YouTube manuals and Shelly documentation.

According to MQTT explorer my login is correct (it can connect) and Shelly is shown there.
I have the feeling there is a mistake somewhere in HASS, because I don’t see added entities as well.

Side note, the integration page in configuration for MQTT does not show any devices…

The integration page never shows manual configured mqtt devices.
In HACs there is a Python script that makes Shelly auto discovered

Even if i take the manual configuration away there are no devices.

Tried the auto discover script, no joy…
Looks like the MQTT messages are not passed in or out the broker.

More information, I can publish commands to Shelly via MQTT explorer.
Something terribly wrong in HASSIO / Mosquitto in my system.

Can you see messages in MQTT Explorer when you use developer tools -> MQTT Publish ? If not, something is wrong with the connection between HA and your broker.

No I don’t see those. Controlling the shelly via MQTT explorer works as expected.

My home assistant log told me the following: unable to connect to the mqtt broker: connection refused: not authorised

Maybe stupid, but I thought I won’t need a username and password in the yaml configuration since it’s a user configured in home assistant users.

Furthermore I don’t see step 3 listed in this documentation: https://www.home-assistant.io/addons/mosquitto/

Step 1 install works,
Step 2 new user works as well
Step 3 integration is telling me configured in configuration.yaml

You will still need the username and password in the MQTT section of your configuration.yaml.

Fixed it in the meantime…
Steps:

  1. Removed all mqtt references in configuration.yaml (including shelly and broker)
  2. Removed mosquitto add-on
  3. Deleted mqtt integration
  4. Deleted mqtt user in user configuration
  5. Reboot
  6. Installed mosquitto add-on
  7. Wait…
  8. Created user in user configuration
  9. Set up integration (it now points to the add-on)
  10. Reboot
  11. Run pyhon shelly discovery automations

It works :slight_smile:

Only thing left is the rest switch…