Just 2 Share the knowledge:
I like home assistant because of the big community, the nice dashboarding and the many many integrations, but i also like domoticz e.g. because of the P1 integration (and the nice reports on it), and the easy way of scripting (HA has no alternative for something like dzVents).
Since I cannot choose between the 2 i decided to use the benefits of both. This is how i do it:
1. Since both support the MQTT AD protocol: For every integration which support is: Add the devices by MQTT AD. This will make the devices available in both instances
2. For those who don't: Using the MQTT Client Interface integration in domoticz to connect the 2. Note: For this to work every device needs to have it's own state topic. So in the settings for MQTT CLient interface, set Publish Topic either to "Index" or "Name"
By setting the interface under 2 you now have the perfect mechanism to have the 2 instances to talk to each other:
For sending devices updates from HA to Domoticz:
- Create a virtual device in domoticz (mirroring the device in home assistant)
- Create an automation in home assistant with the folling properties
- Trigger: The sensor change
- Condition: None
- Action: mqtt.publish with the topic "domoticz/in" and as payload something like { "command": "udevice", "idx": <the idx of your virtual sensor in domoticz>, "nvalue": 0, "svalue": "{{ states.<the sensor name of your sensor in home assistant>.state }}"}
For sending device updates from Domoticz to HA:
- Add the line "mqtt: !include mqtt.yaml" to you homeasistant configuration.yaml
- Create the devices you'd like by describing them in the mqtt.yaml file. :
Code: Select all
sensor:
# Gas usage
- state_topic: "domoticz/out/<index of your domoticz sensor>"
name: "<name of the device>"
value_template: '{{ value_json.svalue1 }}'
unit_of_measurement: '<unit of measurement>'
device_class: <device class>
state_class: <state class>
- <repeat the above lines for every sensor you would like to read from domoticz>
Code: Select all
#P1 meter
sensor:
- state_topic: "domoticz/out/6"
name: "T1"
value_template: '{{ value_json.svalue1 | float / 1000 }}'
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
- state_topic: "domoticz/out/6"
name: "T2"
value_template: '{{ value_json.svalue2 | float / 1000 }}'
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
- state_topic: "domoticz/out/6"
name: "T Total"
value_template: '{{ (value_json.svalue2 | float + value_json.svalue1 | float ) / 1000 }}'
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
- state_topic: "domoticz/out/6"
name: "R1"
value_template: '{{ value_json.svalue3 | float / 1000 }}'
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
- state_topic: "domoticz/out/6"
name: "R2"
value_template: '{{ value_json.svalue4 | float / 1000 }}'
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
- state_topic: "domoticz/out/6"
name: "R total"
value_template: '{{ (value_json.svalue4 | float + value_json.svalue3 | float) / 1000 }}'
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
- state_topic: "domoticz/out/6"
name: "Usage"
value_template: '{{ value_json.svalue5 }}'
unit_of_measurement: "W"
device_class: power
state_class: measurement
- state_topic: "domoticz/out/6"
name: "Delivery"
value_template: '{{ value_json.svalue6 }}'
unit_of_measurement: "W"
device_class: power
state_class: measurement
# Gas usage
- state_topic: "domoticz/out/10"
name: "Gas Verbruik"
value_template: '{{ value_json.svalue1 | float / 1000 }}'
unit_of_measurement: 'm³'
device_class: gas
state_class: total_increasing
# Water usage
- state_topic: "domoticz/out/598"
name: "Water Verbruik"
value_template: '{{ value_json.svalue1 }}'
unit_of_measurement: 'L'
device_class: water
state_class: total_increasing
#Solar Panels
- state_topic: "domoticz/out/31"
name: "Solaredge Delivery Total"
value_template: '{{ value_json.svalue2 | float / 1000 }}'
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
- state_topic: "domoticz/out/31"
name: "Solaredge Actual Delivery"
value_template: '{{ value_json.svalue1 }}'
unit_of_measurement: "W"
device_class: power
state_class: measurement