Hi! Yes, back from holiday!
I will tell you what I’ve got. Don’t know if it is correct or maybe “over done”, but it work so I don’t want to mess with it
(Or someone here can tell that something is not necessary).
Ok, so I have two RPI, one is my Master and the other is just for sending data from my smart meter (Gas and electricity incl. solar numbers).
On MASTER:
- Installed add-on “Mosquitto broker” with this config:
{
“logins”: [],
“anonymous”: true,
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}
-
Install “Integration” “MQTT: Mosquitto Broker” (And here I don’t know if this is correct or that this is double). Can’t see what I’ve written down but I think I gave an username and password here.
-
In configuration.yaml
mqtt_eventstream:
subscribe_topic: slavetopic
-
In configuration.yaml
- platform: mqtt
state_topic: ‘ha/gas_totaal_variabel’
name: ‘totaal_gasverbruik_variabel’
unit_of_measurement: ‘m3’
value_template: ‘{{ value_json.day_1 }}’
On SLAVE
-
In configuration.yaml
mqtt_eventstream:
publish_topic: slavetopic
-
In automation.yaml (one example, but this is for every sensor value I want)
- action:
- service: mqtt.publish
data_template:
topic: ‘ha/gas_totaal_variabel’
retain: true
payload: ‘{“day_1”:"{{ (states.sensor.gas_consumption.state | float) | max (0) | round(3) }}"}’
alias: ‘Gas waarde totaal variabel’
trigger:
platform: state
entity_id: sensor.gas_consumption
And that’s it! Basically what happens (I think) is that when a value in SLAVE is changed the automation will make sure it is send through MQTT. And in MASTER it is said they want to use this sensor reading (point 4)
Hope this helps, otherwise give me another message.
(And will you let me know if it helped you?)
Kind regards,
Eltjo