-
Notifications
You must be signed in to change notification settings - Fork 506
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
use power formatting factors for active power calculation #7978
Open
bluemoehre
wants to merge
7
commits into
dresden-elektronik:master
Choose a base branch
from
bluemoehre:make-power-formatting-factors-available
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+47
−3
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ce3e881
add attributes for power formatting factors
bluemoehre 8cf731d
fix copy paste issue
bluemoehre 3f4da5b
fix access to read-only
bluemoehre 15e5a72
rename description to meet specs
bluemoehre 78289a3
respect power factors to convert active power to Watts
bluemoehre 9835fab
refresh interval of all power items must be equal
bluemoehre 8d423a3
fix calculation
bluemoehre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"schema": "resourceitem1.schema.json", | ||
"id": "state/power_divisor", | ||
"datatype": "UInt16", | ||
"access": "R", | ||
"public": false, | ||
"description": "AC Power Divisor to be divided against the Instantaneous Power and Active Power attributes.", | ||
"read": { | ||
"at": "0x0605", | ||
"cl": "0x0b04", | ||
"ep": 0, | ||
"fn": "zcl:attr" | ||
}, | ||
"parse": { | ||
"at": "0x0605", | ||
"cl": "0x0b04", | ||
"ep": 0, | ||
"eval": "if (Attr.val > 0) { Item.val = Attr.val; }" | ||
}, | ||
"refresh.interval": 300, | ||
"default": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"schema": "resourceitem1.schema.json", | ||
"id": "state/power_multiplier", | ||
"datatype": "UInt16", | ||
"access": "R", | ||
"public": false, | ||
"description": "AC Power Divisor to be divided against the Instantaneous Power and Active Power attributes.", | ||
"read": { | ||
"at": "0x0604", | ||
"cl": "0x0b04", | ||
"ep": 0, | ||
"fn": "zcl:attr" | ||
}, | ||
"parse": { | ||
"at": "0x0604", | ||
"cl": "0x0b04", | ||
"ep": 0, | ||
"eval": "if (Attr.val > 0) { Item.val = Attr.val; }" | ||
}, | ||
"refresh.interval": 300, | ||
"default": 1 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Math.round()
to make sure the reported value is integer.s16
supports values from -32768 to 32767, soAttr.val != 32768
is superfluous. Typically the lowest value, -32768 is used to indicate an invalid value.Unsigned
u16
supports values from 0 to 65535, and uses for 65535 as invalid value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I didn't change that. This code is already in master. Do we need to clean it up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I saw that. Better cleanup while you’re touching it anyways. Sorry to put this on you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reported value is not required to be Integer - am I wrong? JavaScript Number(s) are always floating point. Normally it is up to the UI to take care about display and formatting.
While I was testing with the plug's, I already had problems reporting the standby demand (it was always
0W
in Phoscon, while the RAW value was4
in deCONZ). I can't tell if that's related to this specific code, but for sure if we reduce precision here, we throw away information and my end up not being able to show fractions.EDIT: if we do not want to have float in the JSON, we need to make public alle fields of the 600 formatting block. Then the API client can decide how to deal with that information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the issue is not only related to the files I am touching here, I would like to issue another PR for the cleanup only, to not mix up topics. (It should not matter if that one then gets merged before or after this one, since we can rebase)
#7984
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the cleanup was moved to a dedicated PR and doesn't block us here, is there anything which prevents us continuing? (I don't want to leave this stalled, since it already took multiple days of work)
If the calculation is fine, let's resolve this conversation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ebaauw bump