Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ void DeskCommandSensor::loop() {
// Decide command on byte 5: history[0] is byte 4 (bits 0..6 — Up, Down,
// M1..M3, M-memory, Alarm), incomingByte is byte 5 (bits 8.. — M4 and
// any future high-byte buttons). Both zero == release.
// 5-byte frames (e.g. HS01B-1) have a single payload byte, so byte 5 is
// the checksum there and must not be decoded as a button.
if (this->history[3] == 0x9b) {
if (this->msg_type == 0x02 &&
((this->msg_len == 6) || (this->msg_len == 5))) {
if (this->history[0] != 0) {
this->value = log2(this->history[0] * 2); // 1..7
} else if (incomingByte != 0) {
} else if (this->msg_len == 6 && incomingByte != 0) {
this->value =
8 + log2(incomingByte * 2); // 9 for M4, 10 for M5, ...
} else {
Expand Down
6 changes: 5 additions & 1 deletion packages/office-desk-esp32-passthrough.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ sensor:
id: "desk_command"
name: Desk command
uart_id: keypad_uart
on_value_range: # The sensor outputs values 1 to 8 depending on the button pressed.
on_value_range: # The sensor outputs values 1 to 9 depending on the button pressed.
- above: 1
below: 1
then:
Expand Down Expand Up @@ -151,6 +151,10 @@ sensor:
- switch.turn_off: switch_up
- switch.turn_off: switch_down
- button.press: button_wake_screen
- above: 9
below: 9
then:
- button.press: button_sit

switch:
- platform: gpio
Expand Down
Loading