Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow to divide a register value by a number #501

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

virtualdj
Copy link
Contributor

Add support for a new parameter scale_division in the YAML definition files which allows to divide the register(s) value by a constant number provided. The division is always done after the scaling happened.

This is useful for example for registers that display a value in minutes, but you want the sensor to be in hours: in that case, simply add scale_division: 60 and change the unit of measurement accordingly.

So this sensor:

- name: "Total Generation Time"
  class: ""
  state_class: "measurement"
  uom: "min"
  rule: 3
  registers: [0x0428,0x0427]
  icon: 'mdi:clock-outline'

can be transformed to this:

- name: "Total Generation Time"
  class: ""
  state_class: "measurement"
  uom: "h"
  scale_division: 60
  rule: 3
  registers: [0x0428,0x0427]
  icon: 'mdi:clock-outline'

If you want days from minutes, supply scale_division: 1440 (60 * 24) and so on...
I took the opportunity to fix a bunch of typos in the customization readme, too.

@StephanJoubert StephanJoubert merged commit 8ffb55f into StephanJoubert:main Feb 26, 2024
2 checks passed
@virtualdj virtualdj deleted the feat-scale-division branch February 26, 2024 17:08
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants