We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Has it been considered, or is there already some mechanism to allow the HABaseDeviceType class to track a pointer to user data?
This would allow doing something like this to allow reuse of the call back function:
class ZoneData { public: uint8_t led_pin; uint8_t ssr_pin; ZoneData(uint8_t led_pin, uint8_t ssr_pin) : led_pin(led_pin), ssr_pin(ssr_pin) { } }; WiFiClient client; HADevice device; HAMqtt mqtt(client, device); HASwitch led("led", (void*) new ZoneData( LED_BUILTIN, LED_BUILTIN)); HASwitch zone[] = { HASwitch("Zone0", (void*) new ZoneData( 6, 16)), HASwitch("Zone1", (void*) new ZoneData( 7, 17)), HASwitch("Zone2", (void*) new ZoneData( 8, 18)), HASwitch("Zone3", (void*) new ZoneData( 9, 19)), HASwitch("Zone4", (void*) new ZoneData(10, 20)), HASwitch("Zone5", (void*) new ZoneData(11, 21)), HASwitch("Zone6", (void*) new ZoneData(12, 22)), HASwitch("Zone7", (void*) new ZoneData(13, 26)), HASwitch("Zone8", (void*) new ZoneData(14, 27)), HASwitch("Zone9", (void*) new ZoneData(15, 28)), }; // snip void HAIntegration::switchHandler(bool state, HASwitch* sender) { digitalWrite(((ZoneData*)(sender->getData()))->led_pin, (state ? HIGH : LOW)); digitalWrite(((ZoneData*)(sender->getData()))->ssr_pin, (state ? HIGH : LOW)); sender->setState(state); // report state back to Home Assistant Serial.printf("%s new state: %s (%d, %d)\n", sender->getName(), state ? "on" : "off", ((ZoneData*)(sender->getData()))->led_pin, ((ZoneData*)(sender->getData()))->ssr_pin ); }
The text was updated successfully, but these errors were encountered:
I would be happy to do a pull request for this issue.
Sorry, something went wrong.
No branches or pull requests
Has it been considered, or is there already some mechanism to allow the HABaseDeviceType class to track a pointer to user data?
This would allow doing something like this to allow reuse of the call back function:
The text was updated successfully, but these errors were encountered: