Skip to content

Commit

Permalink
Connect to HA-MQTT using supplied ip
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Apr 22, 2024
1 parent dddc7ab commit 04d647d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/User/UserModHA.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ class UserModHA:public SysModule {
static void onStateCommand(bool state, HALight* sender) {
ppf("State: %s\n", state?"true":"false");

if(state) {
mdl->setValue("bri", 255);
}
else {
mdl->setValue("bri", 0);
}

sender->setState(state); // report state back to the Home Assistant
}

static void onBrightnessCommand(unsigned8 brightness, HALight* sender) {
ppf("Brightness: %s\n", brightness);
ppf("Brightness: %d\n", brightness);

mdl->setValue("bri", brightness);

Expand All @@ -48,6 +55,8 @@ class UserModHA:public SysModule {
mdl->setValue("Green", color.green);
mdl->setValue("Blue", color.blue);

mdl->setValue("fx", 0); // Solid

sender->setRGBColor(color); // report color back to the Home Assistant
}

Expand Down Expand Up @@ -88,7 +97,7 @@ class UserModHA:public SysModule {
mqtt->begin(ip, "", "");
}
else {
spf("Failed to parse %s to IP\n", mqtt.c_str());
ppf("Failed to parse %s to IP\n", mqttAddr.c_str());
}

}
Expand Down

0 comments on commit 04d647d

Please sign in to comment.