Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Hass: Add Translation of states list to value_template map and Notification Command Class first to use this #105

Merged
merged 10 commits into from
Dec 23, 2020
4 changes: 3 additions & 1 deletion lib/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,8 @@ Gateway.prototype.discoverValue = function (node, vId) {
} else {
cfg.object_id = 'notification_' + valueId.property
}

// TODO: Improve the icons for different propertyKeys!
switch (valueId.propertyKey) {
robertsLando marked this conversation as resolved.
Show resolved Hide resolved
case 'Motion sensor status':
cfg.discovery_payload.icon = 'mdi:motion-sensor'
Expand All @@ -1528,7 +1530,7 @@ Gateway.prototype.discoverValue = function (node, vId) {
if (valueId.list) {
cfg.discovery_payload.value_template = getMappedStateTemplate(
valueId.states,
0
valueId.default ? valueId.default : 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure I understood this correctly, IMO when the value is not in the map the value shown should be the one coming from json payload. Id this what's happening here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stand corrected. I did some nice patching on the payload, after manual testing

If valueId.default is undefinied the default value of payload is the value_json.value
this way it really presents the value numeric or other on UI

)
}
break
Expand Down