Skip to content

Commit

Permalink
Add Active state map (#74)
Browse files Browse the repository at this point in the history
* Add Active State Map
  • Loading branch information
Mosibi authored Jan 12, 2025
1 parent 89898f1 commit c6b74de
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.1.0] - 2025-01-12

### Added

- Active State Map: A sensor that represents the state as a number. This can be used for example in Grafana to plot a state time timeline
- 0: Inactive, 1: Heating, 2: Cooling, 3: DHW, 4: Defrosting, 99: Unknown (no mapping found)

## [5.0.0] - 2024-11-24

### Changed
Expand Down
21 changes: 21 additions & 0 deletions heatpump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,27 @@ sensor:
int t1s_dhw = t5 + dt1s5;
return t1s_dhw;
- platform: template
name: "Active State Map"
id: "${devicename}_active_state_map"
unit_of_measurement: ""
accuracy_decimals: 0 # No decimals, value will show as integer
lambda: |-
static const std::map<std::string, int> status_map = {
{"Inactive", 0},
{"Heating", 1},
{"Cooling", 2},
{"DHW", 3},
{"Defrosting", 4}
};
auto state_item = status_map.find(id(${devicename}_active_state).state);
if (state_item != status_map.end()) {
return state_item->second; // Return integer value that matches the string value (Heating, Cooling, etc..)
} else {
return 99; // No mapping found
}
binary_sensor:
# Register: 0 -> Is also read as 'sensor' to read the complete value, used for the templated 'switch'(es)
# Bit: 0 -> Is present in this config as a 'switch'
Expand Down

0 comments on commit c6b74de

Please sign in to comment.