Created
October 3, 2022 18:22
-
-
Save jascdk/49aae816a6b4b213d7036d190b15eaae to your computer and use it in GitHub Desktop.
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
# ----------- Switch ----------- # | |
switch: | |
- platform: modbus_controller | |
name: ${name} INT LOCK ${channel_01_friendly_name} | |
id: ${device}_intlck_${channel_01_id} | |
modbus_controller_id: ${device}_modbus_controller | |
custom_command: | |
- 0x01 | |
- 0x43 | |
- 0x02 | |
- 0x07 | |
- 0x00 # channel 01 (00) | |
- 0x01 | |
write_lambda: |- | |
ESP_LOGD("main","Modbus Switch incoming state for channel 01 = %s",ONOFF(x)); | |
bool state = ONOFF(x); | |
uint8_t MODE_MASK = 0x07; | |
payload.push_back(0x01); | |
payload.push_back(0x45); | |
payload.push_back(0x02); | |
payload.push_back(0x07); | |
payload.push_back(0x00); // channel 01 (00) | |
payload.push_back(0x01); | |
if(x) | |
{ | |
ESP_LOGD("main","Pushing back 0x01 because state is %s",ONOFF(x)); | |
payload.push_back( 0x08); | |
payload.push_back( 0x00); | |
} | |
else | |
{ | |
ESP_LOGD("main","Pushing back 0x00 because state is %s",ONOFF(x)); | |
payload.push_back( 0x00); | |
payload.push_back( 0x00); | |
} | |
payload.push_back(0xF7);//mask to hit bit for int lock | |
payload.push_back(0xFF); | |
return true; | |
lambda: |- | |
int intlck = data[11]; | |
ESP_LOGD("main","intlck for Channel 01 is: %i",intlck); | |
return intlck; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment