Skip to content

Commit

Permalink
fix: sensor cannot set string
Browse files Browse the repository at this point in the history
  • Loading branch information
shaonianzhentan committed Jul 3, 2023
1 parent 351491a commit 282967e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Generate MQTT entities in Home Assistant

English | [简体中文](README.zh.md)

Reference document: https://www.home-assistant.io/docs/mqtt/discovery/
Reference document: https://www.home-assistant.io/integrations/mqtt#mqtt-discovery

## Supported languages
- ✔️ English (en-US)
Expand Down
2 changes: 1 addition & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

[English](README.md) | 简体中文

参考文档:https://www.home-assistant.io/docs/mqtt/discovery/
参考文档:https://www.home-assistant.io/integrations/mqtt#mqtt-discovery

## 支持组件
- [x] alarm_control_panel - 警报面板
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-ha-mqtt",
"version": "1.2.9",
"version": "1.2.10",
"description": "Generate MQTT entities in HomeAssistant",
"keywords": [
"node-red",
Expand Down
2 changes: 1 addition & 1 deletion sensor/sensor.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
<div class="form-row">
<label for="node-input-unit_of_measurement" data-i18n="label.unit"></label>
<input type="text" id="node-input-unit_of_measurement" placeholder="%">
<input type="text" id="node-input-unit_of_measurement">
</div>
<div class="form-row">
<a href="https://www.home-assistant.io/integrations/sensor.mqtt/" target="_blank" style="color:blue;">
Expand Down
5 changes: 3 additions & 2 deletions sensor/sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ module.exports = function (RED) {
})

try {
const discoveryConfig = {
unit_of_measurement: cfg.unit_of_measurement
const discoveryConfig = {}
if(cfg.unit_of_measurement){
discoveryConfig.unit_of_measurement = cfg.unit_of_measurement
}
ha.discovery(discoveryConfig, () => {
this.status({ fill: "green", shape: "ring", text: `node-red-contrib-ha-mqtt/common:publish.config` });
Expand Down

0 comments on commit 282967e

Please sign in to comment.