Agree with Michael's post above, although I don't even enable websockets in my setup for feeding Home Assistant.
Definitely verify with mosquitto_sub, mosquitto_pub, and checking your mosquitto and weewx logs to make sure MQTT is working first.
My setup:
- I display weewx data in a Home Assistant dashboard without any username/passwords in MQTT by defining MQTT sensors and referencing them directly.
- I do not use HA discovery at all.
- No MQTT user/pass is required.
- No MQTT encrypted ports are required.
- No websockets support is required.
MQTT config file is wide open since it's LAN-only and my LAN permits no incoming traffic
listener 1883
allow_anonymous true
MQTT docker-compose.yaml - I run the mosquitto broker in docker,
services:
mosquitto:
restart: unless-stopped
image: eclipse-mosquitto:2.0.18
hostname: mosquitto
container_name: mosquitto
expose:
- "1883"
ports:
- "1883:1883"
volumes:
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
- /mnt/mosquitto/log:/mosquitto/log
In weewx.conf
[[MQTT]]
enable = true
client_id = vp2
server_url = mqtt://192.168.1.69:1883/
append_units_label = false
binding = loop,archive
topic = vp2
aggregation = aggregate
log_success = false # set true for 'very' verbose logging
log_failure = true
In the HA configuration.yaml file
mqtt: !include mqtt.yaml
In the HA mqtt.yaml file
sensor:
- name: "Gust"
device_class: "speed"
state_topic: "vp2/loop"
unique_id: 4e482881-716c-4fc9-bfd1-89e0d12e139e
unit_of_measurement: 'mph'
value_template: "{{ value_json.windGust | float | round(0) }}"
- name: "GustDir"
device_class: "wind_direction"
state_topic: "vp2/loop"
unique_id: ae12ec9b-50d9-4b68-85f8-960984d62c61
value_template: "{{ value_json.windGustDir | float | round(0) }}"
- name: "Rain"
device_class: "precipitation"
state_topic: "vp2/loop"
unique_id: f4918e00-e9b0-4e0b-ba03-41b5340d3775
unit_of_measurement: 'in'
value_template: "{{ value_json.dayRain | float | round(2) }}"
- name: "Outside"
device_class: "temperature"
state_topic: "vp2/loop"
unique_id: a027cb3d-e90a-44eb-b3ca-53292df4d174
unit_of_measurement: '°F'
value_template: "{{ value_json.outTemp | float | round(1) }}"
In the yaml for my dashboard....I use a 'ring-tile' to display a gauge with colorization in the outer ring based on temperature...
"cards": [
{
"type": "horizontal-stack",
"cards": [
{
"type": "custom:ring-tile",
"entity": "sensor.outside",
"scale": "ticks_with_labels",
"middle_element": "value_with_unit",
"bottom_element": "name",
"ring_size": 3,
"name": "Outside",
"min": 0,
"max": 110,
"max_decimals": 0,
"min_decimals": 0,
"ring_only": true,
"colour": {
"0": "ha_blue",
"40": "cyan",
"60": "lightgreen",
"70": "green",
"80": "ha_orange",
"90": "ha_red"
},
"card_mod": {
"style": "ha-card {\n background: rgb(217,217,217);\n border: 0px;\n}\n"
}
},
(and so on)