Skip to content

Commit

Permalink
Merge pull request #20 from psi-4ward/fix/heater
Browse files Browse the repository at this point in the history
fix(heater): Wrong schema; HA discovery broken
  • Loading branch information
dixi83 authored Jan 14, 2025
2 parents ecdab3f + 76a2ee0 commit a0e42ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion config_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ properties:
required:
- type
- name
- state
- current_temperature
- target_temperature
# Button specific schema
Expand Down
3 changes: 2 additions & 1 deletion device.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = class device {
this.discovery_topic = "homeassistant";
this.discovery_retain = false;
this.type = config["type"].toLowerCase();
this.ha_component = this.type; // default is the type but can be overwritten

// device topics
this.mqtt_name = config["mqtt"];
Expand Down Expand Up @@ -98,7 +99,7 @@ module.exports = class device {
send_discover_msg(info) {
// create a topic in which the discovery message can be sent
let topic = this.discovery_topic + "/" +
this.type + "/" +
this.ha_component + "/" +
this.config["mqtt_base"] + "/" +
this.mqtt_name + "/config";

Expand Down
3 changes: 3 additions & 0 deletions devices/heater.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module.exports = class devHeater extends device {
constructor(plc, mqtt, config, mqtt_base) {
super(plc, mqtt, config, mqtt_base);

// Overwrite the type of the home assistant component because it does not match the device type
this.ha_component = 'climate';

// current temperature
if (config["current_temperature"]) {
this.create_attribute(config["current_temperature"], this.getDatatype(config['current_temperature']), "current_temperature");
Expand Down

0 comments on commit a0e42ee

Please sign in to comment.