Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- change temperature format to json
- change channel_level format to json
  • Loading branch information
matthew-larner committed Jul 23, 2024
1 parent 05da76e commit 2204c15
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
24 changes: 17 additions & 7 deletions src/entities/dynaliteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,23 @@ export const commandsHandler = ({
};
const processTemperature = (x: number, y: number) => {
const temp = (Math.round(parseFloat(`${x}.${y}`) * 10) / 10).toString();
sendMqttTemperatureMessage(temp);

let payload: object;
payload = { temperature: temp };

sendMqttStateMessage(JSON.stringify(payload));
}
const processHvac = (data: string) => {
sendMqttStateMessage(data);
const processHvac = (value: number) => {
let payload: object;
payload = { channel_level: value };

sendMqttStateMessage(JSON.stringify(payload));
};
const processChannelLevel = (data: string) => {
sendMqttStateMessage(data);
const processChannelLevel = (value: number) => {
let payload: object;
payload = { channel_level: value };

sendMqttStateMessage(JSON.stringify(payload));
};

if (thirdDecimal === 17) {
Expand All @@ -81,9 +91,9 @@ export const commandsHandler = ({
} else if (thirdDecimal === 87) {
processTemperature(data[10], data[11]);
} else if (thirdDecimal === 86) {
processHvac(data[10].toString());
processHvac(data[10]);
} else if (thirdDecimal === 16) {
processChannelLevel(data[12].toString());
processChannelLevel(data[12]);
} else {
console.log('Dynalite ignored message 3rd character decimal:', thirdDecimal);
}
Expand Down
5 changes: 3 additions & 2 deletions src/entities/homeAssistantHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ export const startup = ({
name: `${bridges.area[areaKey].name} ${channelName}`,
unique_id: name.toLowerCase().replace(/ /g, "_"),
device_class: "temperature",
state_topic: `${mqttConfig.topic_prefix}/a${areaKey}c${channelKey}/temp`,
state_topic: `${mqttConfig.topic_prefix}/a${areaKey}c${channelKey}/state`,
availability_topic: `${mqttConfig.availability_topic}`,
unit_of_measurement: "°C"
unit_of_measurement: "°C",
value_template: "{{ value_json.temperature }}"
};
} else {
// skip other types
Expand Down

0 comments on commit 2204c15

Please sign in to comment.