Skip to content

Commit

Permalink
Merge pull request #175 from Smankusors/config-payload-enhancement
Browse files Browse the repository at this point in the history
MQTT config payload enhancements
  • Loading branch information
Sennevds authored Apr 3, 2024
2 parents c5ba97b + 73aecb8 commit 00284b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/system_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ def send_config_message(mqttClient):
payload = (f'{{'
+ (f'"device_class":"{attr["class"]}",' if 'class' in attr else '')
+ (f'"state_class":"{attr["state_class"]}",' if 'state_class' in attr else '')
+ f'"name":"{deviceNameDisplay} {attr["name"]}",'
+ f'"name":"{attr["name"]}",'
+ f'"state_topic":"system-sensors/sensor/{devicename}/state",'
+ (f'"unit_of_measurement":"{attr["unit"]}",' if 'unit' in attr else '')
+ f'"value_template":"{{{{value_json.{sensor}}}}}",'
+ f'"object_id":"{devicename}_{attr["sensor_type"]}_{sensor}",'
+ f'"unique_id":"{devicename}_{attr["sensor_type"]}_{sensor}",'
+ f'"availability_topic":"system-sensors/sensor/{devicename}/availability",'
+ f'"device":{{"identifiers":["{devicename}_sensor"],'
Expand Down

0 comments on commit 00284b9

Please sign in to comment.