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

Conversation

varet80
Copy link
Collaborator

@varet80 varet80 commented Dec 21, 2020

Make Sensors of Notification CC provide translated values to Home assistant.

An example is Motion sensors. While the state is 0 or 8, this is not a nice to look into.
The real values per z-wave specification are idle and 'Motion detection'.

This patch converts the sensor values showin in HASS in human readable form.

Screenshot 2020-12-22 at 09 01 57

@coveralls
Copy link

coveralls commented Dec 21, 2020

Pull Request Test Coverage Report for Build 438698385

  • 14 of 42 (33.33%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 28.553%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/Gateway.js 14 42 33.33%
Files with Coverage Reduction New Missed Lines %
lib/Gateway.js 1 20.35%
lib/ZwaveClient.js 2 0%
Totals Coverage Status
Change from base Build 436542969: 0.01%
Covered Lines: 1950
Relevant Lines: 6973

💛 - Coveralls

@varet80 varet80 changed the title [WIP] [feat] Hass: Add Translation of states list to value_template map and Notification Command Class first to use this [feat] Hass: Add Translation of states list to value_template map and Notification Command Class first to use this Dec 22, 2020
@varet80 varet80 requested a review from robertsLando December 22, 2020 09:19
lib/Gateway.js Outdated Show resolved Hide resolved
lib/Gateway.js Outdated
@@ -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

Copy link
Member

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

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

LGTM

@robertsLando robertsLando merged commit 0bc3d5e into master Dec 23, 2020
@robertsLando robertsLando deleted the hassNotificationListTraslation branch December 23, 2020 09:37
ahochsteger pushed a commit that referenced this pull request Dec 27, 2020
* add notification part 1

* add translation from states to value_template

* support both number and text

* add motion sensor icon

* add new icon for motion sensor

* add TODO for icons. Add logic on mapped default value

* patch default value, to show value_json.value when uknown mapping entry is posted

* remove extra bracket

* fix linting issues

Co-authored-by: V. Aretakis <[email protected]>
@varet80 varet80 restored the hassNotificationListTraslation branch January 7, 2021 13:59
@varet80 varet80 deleted the hassNotificationListTraslation branch February 23, 2021 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants