Understanding Mqtt basics

Hey Mike, thanks for that. I am running the version 1.21 forked firmware, and the options have changed a bit. I thought for a second you figured it out as i did not enable notifications and for sure thought that was it. Other people on this forum are running 1.21 and it is working but it could be a bad flash or something. here is the screenshot. When i go into MQTT explorer and connect to my broker, i can see in the Mosquitto logs my laptop’s ip that has MQTT explorer on it, so that is working. Nothing from the opengarage though.

hey guys, finally figured this out. I just upgraded my Pfsense router and right on the main page i just happen to see a bunch of denies in the firewall logs. I block traffic between the IOT vlan and my regular LAN where my Home Assistant VM’s live. Soon as i made a rule to allow the garagedoor traffic to home assistant, this is what i got:

really appreciate everyone’s help. now i can go through this thread and try to actually get it working. maybe someone can have a look at my config to get the switch and distance setting working.

I guess the config you have still yeilds no results? Have you tried listen to # through the mqtt integration? you should see messages there from OpenGarage. They need to be there for this to work. Post the message if it shows up there.

Hey Mike, none of my sensors work or the buttons but i can see mqtt messages coming in. Looks like it is about every 15 seconds, don’t know if that is from HA polling the opengarage. I have my production system using the Opengarage integration running at the same time. I am setting this up on a test system so i don’t screw up my working system. Here is a quick screenshot from mqtt… just trying to see if i can publish a command to open the door via mqtt.

I’m guessing that I’m in the minority. I never cared for the idea of having to run MQTT. so I have not. I have dozens and dozens of devices (zwave, wifi, ESPhome, mysensors(rf) ,etc) and have never needed it. everything I use can talk directly to HA. so for me, it just seems to be an extra layer that isn’t necessary. but with things like zwave2mqtt / JS coming, it seems like I may have to run it at some point.

same here, i have a bunch of Casetta lights, LIFX, TPlink, and Inovelli and don’t really need it. I just read that the opengarage unit doesn’t really like being polled every dozen seconds or so. I was hoping by using MQTT that the opengarage would push info to HA instead of being polled every few seconds. Not sure if i am right but we close the garage at 9pm or whatever and don’t use the garage until 7 am the next morning. That’s a lot of polling if not needed. Also like you say with the zwave2mqtt becoming standard, I thought it would be good getting some exposure before i drop the depreciated 1.4.

Something still seems off I’d expect more messages for distance/occupancy. If you publish on the configuration page opengarage/open does that open the door?

Here is a screen of mqtt explorer. was able to go into mqtt explorer and publish open to the topic GarageDoor/IN/STATE and the friggen door opened, I can’t believe it, lol.

most things seem to work except the Garage Door Status, it says unavailable. I added a car in garage icon by cutting my code from the working setup. I don’t think it’s right because my working setup uses a binary sensor where this way uses distance state, not sure that matters. here is the code in case anyone is searching around one day.


sensor:
  - platform: template
    sensors:
      garage_door_status:
        friendly_name: 'Garage Door Status'
        value_template: '{{states.cover.GarageDoor.state}}'
      garage_vehicle_state:
        friendly_name: "Car In Garage"
        value_template: >-
          {% if states.sensor.GarageDoor_distance.state | int == 0 %}
          Disabled
          {% elif (states.sensor.GarageDoor_distance.state | int > 0) and (states.sensor.GarageDoor_distance.state | int <= 80) %}
          Unknown (Door Open)
          {% elif (states.sensor.GarageDoor_distance.state | int > 80) and (states.sensor.GarageDoor_distance.state | int <= 150) %}
          Yes
          {% else %} 
          No
          {% endif %}
        icon_template: >-
          {% if is_state('sensor.GarageDoor_distance.state','on') %}
          mdi:car
          {% else %}
          mdi:car-arrow-right
          {% endif %}

  - platform: mqtt
    name: "GarageDoor Distance"
    state_topic: "GarageDoor/OUT/DIST"
    unit_of_measurement: "cm"
     
      
cover:
     - platform: mqtt
       name: "Garage Door"
       command_topic: "GarageDoor/IN/STATE"
       state_topic: "GarageDoor/OUT/STATE"
       state_open: "OPEN"
       state_closed: "CLOSED"
       payload_open: "open"
       payload_close: "close"
       device_class: "garage"

try

  - platform: mqtt
    state_topic: GarageDoor/OUT
    value_template: "{{ value_json.DIST }}"
    unit_of_measurement: "cm"
    name: "GarageDoor Distance"

E. change formatting, added a space after DIST

thanks for this man, will try tomorrow after work!

tried that code and got this:

you need to change all of your sensor entity_id’s to all lowercase:

states.sensor.garagedoor_distance.state

all entity_id’s are always lowercase.

thx, will give it a try.

Hi there,

I’m trying to convert my old mqtt code from Openhab over to Home assistant. I managed to work out the mqtt commands for my lights, but I’m struggling a little bit on the BME280 climate sensors. Could anyone assist me?

Here is the working code from my Openhab file:

Number   Sensor_OutsideTemperature    "Outside Air Temp [%.1f °C]"   <temperature> (GF_Driveway,gSensorTemperature) [ "CurrentTemperature"]  { mqtt="<[broker:tele/outsidetemp/SENSOR:state:JSONPATH($.BME280.Temperature)]", expire="11m, state=5" }
Number   Sensor_OutsideHumidity       "Outside Air Humidity [%.1f %%]"   <humidity>    (GF_Driveway,gSensorHumidity)     { mqtt="<[broker:tele/outsidetemp/SENSOR:state:JSONPATH($.BME280.Humidity)]", expire="11m, state=0" }
Number   Sensor_OutsidePressure       "Outside Pressure [%.1f bar]"  <pressure>    (GF_Driveway,gSensorPressure)     { mqtt="<[broker:tele/outsidetemp/SENSOR:state:JSONPATH($.BME280.Pressure)]", expire="11m, state=0" }

And using a mqtt client I can retrieve temperature data from the above Topic: tele/outsidetemp/SENSOR using the JSON converter entry of: $.BME280.Temperature

I have tried this following entry in my Home Assistant .yaml:

sensor:
   - platform: mqtt
     state_topic: tele/outsidetemp/sensor
     value_template: "{{ value_json.BME280.Temperature }}"
     unit_of_measurement: "[%.1f °C]"
     name: "Outside Temeperature"

And while i now have an entity of “sensor.outside_temeperature”, when I check this entity in the Configuration/Entity there is a red exclamation mark and the message states: “This entity (“sensor.outside_temeperature”) does not have a unique ID, therefore its settings cannot be managed from the UI”.

As each BME280 has Temperature, Humidity and Pressure, I would like to transpose these over in to Home Assistant.

Any help and guidance greatly welcomed!

Thank you angusc

These are actually 2 things :

“This entity (“sensor.outside_temeperature”) does not have a unique ID, therefore its settings cannot be managed from the UI”. is a normal message for entities that are configured in .yaml. It simply means what it says : its settings cannot be managed from the UI, you have to change your yaml to change things.

red exclamation mark : That is because there is some error in your configuration. I would try :

sensor:
   - platform: mqtt
     state_topic: tele/outsidetemp/sensor
     value_template: "{{ value_json.BME280.Temperature }}"
     unit_of_measurement: "°C"
     name: "Outside Temperature"

and see if you still have the exclamation mark.

1 Like

Thank you @francisp

That assisted me to get to this working point:

sensor:
# Outside Sensor
   - platform: mqtt
     state_topic: tele/outsidetemp/SENSOR
     value_template: '{{ (value_json.BME280.Temperature - 0)|float|round(2)}}'
     unit_of_measurement: "°C"
     name: "Outside Temperature"
   - platform: mqtt
     state_topic: tele/outsidetemp/SENSOR  
     value_template: '{{ (value_json.BME280.Humidity - 0)|float|round(2)}}'
     unit_of_measurement: "%"
     icon: mdi:water-percent
     name: "Outside Humidity"
   - platform: mqtt
     state_topic: tele/outsidetemp/SENSOR  
     value_template: '{{ (value_json.BME280.Pressure - 0)|float|round(2)}}'
     unit_of_measurement: "Bar"
     icon: mdi:atm
     name: "Outside Pressure"