MQTT to HA issues

Hoping to find a solution here. I’ve been chewing my keyboard out of frustration since I can’t seem to get simple things to work. I have to say HA and everything around it is extremely complicated to figure out if you’re not a programmer. I’m a networker so struggling with the programming lingo everywhere.

I have HA (not HASS) running on my Syno in a docker container. There I also have Node-Red and Mosquitto running in seperate containers.

HA seems to be working fine, I connected my Hue lights to it and everything shows up automatically on the dahboard. All good there. Now I have a bunch of Shellies I want to connect using MQTT and that’s where I run into issues (probably due to my lack of knowledge of anything over OSI layer4…)

If I check with MQTT explorer, I can see the shellies connect to my broker so the broker is fine and the shellies report to the broker fine. Somehow I can’t get those devices into HA whichever way I try.

  1. in HA -> configuration -> integration - MQTT added but I’m not discovering any devices apparently. If I read about that it’s normal shellies are not discovered but it should show up under entities… which doesn’t happen for me.

  2. https://github.com/StyraHem/ShellyForHASS. Had to install the python scripts manually since I don’t have the community option in my dashboard so also no HACS (I have no idea why I don’t but one issue at the time) As soon as I add “shelly:” to my configuration.yaml I get an error message when starting HA.

  3. Discovery -> Shellies Discovery Script Added the Python_scripts folder and put the script in that folder and added the “minimal configuration” to the configuration.yaml file… yet no entities appear.

Lastly; I have also installed node-red and there I seem to get output from the shellies so the broker really seems to be working so now I’m lost. Anyone got any suggestions? Not trying to be lazy here but the more I read the more confused I get on all of this.

Lots going on here so let me try to breakdown;

HACS / Community is not included by default and has to be installed. That is why it is not showing for you.

If your mqtt devices don’t report their config in the HA format on a topic that HA is configured to use for discovery (by default: “homeassistant”), then you have to manually configure each device in HA. You can see some examples of that on the HA website components section under the Mqtt sections. You’ll need to modify according to the details you have seen from your devices in mqtt app.

Also, I’m not familiar with “Shellies” not the custom modules you mention trying to use. But if they are available via HACS, I’d highly suggest installing via that route rather than manual install.

Also, you said you have “HA not HASS”, did you mean “HA not HassIO” or were you referring to not using the German word?

Thanks for the response.

Regarding HASS, sorry, I did mean that I’m not running HASSIO. I’m using HA. Happy to run HASSIO but I’d like to run it on my Synology since I don’t want to run it on a RPI or a NUC. From what I read I cannot get communities on HA, that only works with HASSIO.

Regarding the MQTT devices not reporting their config - should I not first see the MQTT devices under entities like the HUE devices? That’s what I would expect. After that, I can start working out which topics I need to do something with.

Is this correct or am I missing something here?

Not all devices can be automatically discovered by Home Assistant. The device must advertise its presence on the network (using a known protocol) to be discovered.

For devices that speak MQTT, Home Assistant’s developers have devised a means for them to announce their presence to Home Assistant. It’s called MQTT Discovery and basically it’s a specification for the device to share details about itself. If the device implements this specification, it publishes its details to MQTT topics beginning with the root-topic homeassistant. Home Assistant monitors that root-topic and incorporates any devices it finds there.

If the device does not support Home Assistant’s MQTT Discovery specification, then you manually create a configuration for it (configuration.yaml). It’s not difficult. I have dozens of MQTT-based devices that I’ve configured manually. For example, here’s the config for the switch that controls my pool pump:

switch:
  - platform: mqtt
    name: "Pool Pump"
    state_topic: "premise/pool/pump/powerstate"
    command_topic: "premise/command/pool/pump/powerstate"
    payload_on: "1"
    payload_off: "0"
    state_on: "1"
    state_off: "0"

Which model(s) of Shelly device are you using?

SSH to HA.
Use command to see all:

mosquitto_sub -u USER_NAME -P PASSWORD -v -t # -h IP_ADDRESS_OF_Synology

Shellies don’t speak “Home Assistant” on their own. So, while they report to MQTT if you set them up that way, they don’t report in a way that Home Assistant can auto discover. This means you either need to use one of the many shelly custom_componets. Or you need to “manually discover” them.

I use the python_script found here to handle this:

You can also just define it in configuration.yaml like this:

switch:
  - platform: mqtt
    name: masterbath_exhaustfan
    state_topic: "shellies/shellyswitch-XXXXXX/relay/1"
    command_topic: "shellies/shellyswitch-XXXXXX/relay/1/command"
    payload_on: "on"
    payload_off: "off"
    retain: false

Guys - Thanks a lot for the responses. Starting to make a little more sense now. Not working yet though but what I did;

  • in the configuration.yaml file added:
# MQTT integration
mqtt:
  broker: 192.168.40.40

and added a Shelly device;

switch:
  - platform: mqtt
    name: Garage
    state_topic: "shellies/shelly1-E0EA72/relay/0"
    command_topic: "shellies/shelly1-E0EA72/relay/0/command"
    payload_on: "on"
    payload_off: "off"
    retain: false

This didn’t work so I decided to remove the MQTT broker from the Integrations page.

Now when I open the integrations page it says; “MQTT: Configuration.yaml” instead of MQTT broker.

I would expect the Shelly to show up as an entity yet it doesn’t. Anything else I need to do?

EDIT:

WAIT WAIT WAIT WAIT!!! If I click on “unused entities” it DOES show up as switch AND it works!

… why don’t I see this at the “Entity Registry” page though?

(I’d like to understand HA way better than i currently do…)

In entity registry you will see only entities with unique_id parameter. If you will use Shellies Discovery script entities will show in integrations and entity registry.

Usually what you see there has been discovered by Home Assistant and automatically assigned a unique_id. If you add this line to your switch’s configuration:

    unique_id: ABC123XYZ

then restart Home Assistant, the switch will appear in the entity registry. However, there’s NO obligation to do this …

Back to an earlier comment. Hacs is available on all installations of home assistant, not just hassio. Just follow the very clear instructions.

Thanks guys - very helpful!

I’m running Ha, not HASSIO. for HASSIO, yes clearly documented but where can I find how to get the communities/HACS on HA?

I was able to follow the directions very easily last night…it has nothing to do with hassio. I simply pulled up the page for hacs and there were the instructions

For the avoidance of doubt, the instructions are here https://custom-components.github.io/hacs/installation/manual/