Skip to content

Commit

Permalink
yield in mqtt publish
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Jan 29, 2025
1 parent d9b84b9 commit 53d06b8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/yasolr_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ static void haDiscovery() {
haDiscovery.publish(Mycila::HA::Value("network_wifi_mac_address", "Net: WiFi MAC Address", "/system/network/wifi/mac_address", nullptr, "mdi:lan", Mycila::HA::Category::DIAGNOSTIC));
haDiscovery.publish(Mycila::HA::Value("network_wifi_ssid", "Net: WiFi SSID", "/system/network/wifi/ssid", nullptr, "mdi:wifi", Mycila::HA::Category::DIAGNOSTIC));
haDiscovery.publish(Mycila::HA::State("network_ntp", "Net: NTP", "/system/network/ntp", YASOLR_ON, YASOLR_OFF, "connectivity", nullptr, Mycila::HA::Category::DIAGNOSTIC));
yield();

// CONFIG

Expand All @@ -356,6 +357,7 @@ static void haDiscovery() {
haDiscovery.publish(Mycila::HA::Text("output1_temperature_stop", "Output 1 Temperature Stop", "/config/" KEY_OUTPUT1_TEMPERATURE_STOP "/set", "/config/" KEY_OUTPUT1_TEMPERATURE_STOP, "^\\d{1,3}$", "mdi:thermometer-alert", Mycila::HA::Category::CONFIG));
haDiscovery.publish(Mycila::HA::Text("output1_time_start", "Output 1 Time Start", "/config/" KEY_OUTPUT1_TIME_START "/set", "/config/" KEY_OUTPUT1_TIME_START, "^\\d?\\d:\\d\\d$", "mdi:clock-time-ten", Mycila::HA::Category::CONFIG));
haDiscovery.publish(Mycila::HA::Text("output1_time_stop", "Output 1 Time Stop", "/config/" KEY_OUTPUT1_TIME_STOP "/set", "/config/" KEY_OUTPUT1_TIME_STOP, "^\\d?\\d:\\d\\d$", "mdi:clock-time-six", Mycila::HA::Category::CONFIG));
yield();

haDiscovery.publish(Mycila::HA::Number("output2_dimmer_limiter", "Output 2 Limiter", "/config/" KEY_OUTPUT2_DIMMER_LIMIT "/set", "/config/" KEY_OUTPUT2_DIMMER_LIMIT, Mycila::HA::NumberMode::SLIDER, 0, 100, 1, "mdi:flash", Mycila::HA::Category::CONFIG));
haDiscovery.publish(Mycila::HA::Switch("output2_auto_bypass", "Output 2 Auto Bypass", "/config/" KEY_ENABLE_OUTPUT2_AUTO_BYPASS "/set", "/config/" KEY_ENABLE_OUTPUT2_AUTO_BYPASS, YASOLR_TRUE, YASOLR_FALSE, "mdi:water-boiler-auto", Mycila::HA::Category::CONFIG));
Expand All @@ -365,6 +367,7 @@ static void haDiscovery() {
haDiscovery.publish(Mycila::HA::Text("output2_temperature_stop", "Output 2 Temperature Stop", "/config/" KEY_OUTPUT2_TEMPERATURE_STOP "/set", "/config/" KEY_OUTPUT2_TEMPERATURE_STOP, "^\\d{1,3}$", "mdi:thermometer-alert", Mycila::HA::Category::CONFIG));
haDiscovery.publish(Mycila::HA::Text("output2_time_start", "Output 2 Time Start", "/config/" KEY_OUTPUT2_TIME_START "/set", "/config/" KEY_OUTPUT2_TIME_START, "^\\d?\\d:\\d\\d$", "mdi:clock-time-ten", Mycila::HA::Category::CONFIG));
haDiscovery.publish(Mycila::HA::Text("output2_time_stop", "Output 2 Time Stop", "/config/" KEY_OUTPUT2_TIME_STOP "/set", "/config/" KEY_OUTPUT2_TIME_STOP, "^\\d?\\d:\\d\\d$", "mdi:clock-time-six", Mycila::HA::Category::CONFIG));
yield();

// SENSORS

Expand All @@ -376,28 +379,32 @@ static void haDiscovery() {
haDiscovery.publish(Mycila::HA::Gauge("grid_power_virtual", "Grid Power Without Routing", "/router/virtual_grid_power", "power", nullptr, "W"));
haDiscovery.publish(Mycila::HA::Gauge("grid_power_factor", "Grid Power Factor", "/grid/power_factor", "power_factor"));
haDiscovery.publish(Mycila::HA::Gauge("grid_voltage", "Grid Voltage", "/grid/voltage", "voltage", nullptr, "V"));
yield();

haDiscovery.publish(Mycila::HA::Counter("routed_energy", "Routed Energy", "/router/energy", "energy", nullptr, "Wh"));
haDiscovery.publish(Mycila::HA::Gauge("routed_power", "Routed Power", "/router/power", "power", nullptr, "W"));
haDiscovery.publish(Mycila::HA::Gauge("router_power_factor", "Router Power Factor", "/router/power_factor", "power_factor"));
haDiscovery.publish(Mycila::HA::Gauge("router_temperature", "Router Temperature", "/router/temperature", "temperature", "mdi:thermometer", "°C"));
haDiscovery.publish(Mycila::HA::Value("router_lights", "Router Lights", "/router/lights", nullptr, "mdi:cards-heart"));
yield();

haDiscovery.publish(Mycila::HA::Outlet("relay1", "Relay 1", "/router/relay1/set", "/router/relay1", YASOLR_ON, YASOLR_OFF));

haDiscovery.publish(Mycila::HA::Outlet("relay2", "Relay 2", "/router/relay2/set", "/router/relay2", YASOLR_ON, YASOLR_OFF));
yield();

haDiscovery.publish(Mycila::HA::Value("output1_state", "Output 1", "/router/output1/state"));
haDiscovery.publish(Mycila::HA::State("output1_bypass", "Output 1 Bypass", "/router/output1/bypass", YASOLR_ON, YASOLR_OFF, "running"));
haDiscovery.publish(Mycila::HA::Number("output1_dimmer_duty", "Output 1 Dimmer Duty Cycle", "/router/output1/duty_cycle/set", "/router/output1/duty_cycle", Mycila::HA::NumberMode::SLIDER, 0.0f, 100.0f, 0.01f, "mdi:water-boiler"));
haDiscovery.publish(Mycila::HA::Outlet("output1_relay", "Output 1 Bypass", "/router/output1/bypass/set", "/router/output1/bypass", YASOLR_ON, YASOLR_OFF));
haDiscovery.publish(Mycila::HA::Gauge("output1_temperature", "Output 1 Temperature", "/router/output1/temperature", "temperature", "mdi:thermometer", "°C"));
yield();

haDiscovery.publish(Mycila::HA::Value("output2_state", "Output 2", "/router/output2/state"));
haDiscovery.publish(Mycila::HA::State("output2_bypass", "Output 2 Bypass", "/router/output2/bypass", YASOLR_ON, YASOLR_OFF, "running"));
haDiscovery.publish(Mycila::HA::Number("output2_dimmer_duty", "Output 2 Dimmer Duty Cycle", "/router/output2/duty_cycle/set", "/router/output2/duty_cycle", Mycila::HA::NumberMode::SLIDER, 0.0f, 100.0f, 0.01f, "mdi:water-boiler"));
haDiscovery.publish(Mycila::HA::Outlet("output2_relay", "Output 2 Bypass", "/router/output2/bypass/set", "/router/output2/bypass", YASOLR_ON, YASOLR_OFF));
haDiscovery.publish(Mycila::HA::Gauge("output2_temperature", "Output 2 Temperature", "/router/output2/temperature", "temperature", "mdi:thermometer", "°C"));
yield();

haDiscovery.end();
}
Expand Down

0 comments on commit 53d06b8

Please sign in to comment.