Skip to content
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

status topic omitted from config payload when declaring multiple HAMqttDevices #4

Open
dh-create opened this issue Apr 30, 2021 · 0 comments

Comments

@dh-create
Copy link

When attempting to declare both a SWITCH and BINARY SENSOR in the same arduino sketch I noticed some strange behaviour - for the second device declared, the status topic (stat_t) was omitted from the config payload which appears to be causing homeassistant to fail to import the sensor. i.e. in the example below, garagedoorZSC wouldn't include stat_t even if I manually included garagedoorZSC.enableStateTopic();. If I reversed the following two lines, 'garagedoorZSC' would now include stat_t but 'garagedoor' would not.

HAMqttDevice garagedoor("11HS002 GD DEV", HAMqttDevice::SWITCH, "homeassistant");
HAMqttDevice garagedoorZSC("11ZSC002 DEV", HAMqttDevice::BINARY_SENSOR, "homeassistant");

Arduino code and outputs from serial for the two different cases:

HAMqttDevice garagedoor("11HS002 GD DEV", HAMqttDevice::SWITCH, "homeassistant");
HAMqttDevice garagedoorZSC("11ZSC002 DEV", HAMqttDevice::BINARY_SENSOR, "homeassistant");
<timestamp etc cutoff in serial monitor>Config topic : homeassistant/switch/11hs002_gd_dev/config
22:48:39.071 -> Config payload : {"~":"homeassistant/switch/11hs002_gd_dev","name":"11HS002 GD DEV","cmd_t":"~/cmd","stat_t":"~/state"}
22:48:39.106 -> Config topic : homeassistant/binary_sensor/11zsc002_dev/config
22:48:39.106 -> Config payload : {"~":"homeassistant/binary_sensor/11zsc002_dev","name":"11ZSC002 DEV"}
// Home Assitant device creation for MQTT discovery
HAMqttDevice garagedoorZSC("11ZSC002 DEV", HAMqttDevice::BINARY_SENSOR, "homeassistant");
HAMqttDevice garagedoor("11HS002 GD DEV", HAMqttDevice::SWITCH, "homeassistant");
<timestamp etc cutoff in serial monitor>Config topic : homeassistant/switch/11hs002_gd_dev/config
22:49:29.900 -> Config payload : {"~":"homeassistant/switch/11hs002_gd_dev","name":"11HS002 GD DEV","cmd_t":"~/cmd"}
22:49:29.900 -> Config topic : homeassistant/binary_sensor/11zsc002_dev/config
22:49:29.900 -> Config payload : {"~":"homeassistant/binary_sensor/11zsc002_dev","name":"11ZSC002 DEV","stat_t":"~/state"}

thanks, Dave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant