-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add support for text message as payload #13
Comments
Hi @raducatanet The feature is available on the develop branch. Please note that I have refactored HASensor that is not compatible with the previous implementation (see: https://github.com/dawidchyrzynski/arduino-home-assistant/blob/develop/examples/sensor/sensor.ino). |
Hi @raducatanet Thank you for the details! I really appreciate your effort in improving this library. OFF label in the panel is displayed due to "action" property of the HVAC. Home Assistant's documentation doesn't clearly state what's the difference between "action" and "mode". The "action" may be only produced by the device (there is no command for changing it). I suppose this was created for thermostats that have physical buttons for HVAC operations, so in such case "action" is used instead of "mode". You correctly noticed that in the current approach this doesn't make sense so I decided to add a new HVAC feature called "ActionFeature". You may implement your HVAC in two different ways:
|
I'm not able to reproduce the problem. The only thing that comes to my mind is connection problem due to quality (e.g. long range connection with access point). Can you try this example: #include <ESP8266WiFi.h>
#include <ArduinoHA.h>
#define BROKER_ADDR IPAddress(192,168,0,28)
#define WIFI_SSID "YourSSID"
#define WIFI_PASSWORD "YourPassword"
WiFiClient client;
HADevice device;
HAMqtt mqtt(client, device);
// see src/device-types/HAHVAC.h header for more details
HAHVAC hvac("Home_Thermostat");
unsigned long lastTempPublishAt = 0;
double lastTemp = 0;
void onTargetTemperatureChanged(double temp) {
Serial.print("Target temperature: ");
Serial.println(temp);
}
void onModeChanged(HAHVAC::Mode mode) {
Serial.print("Mode: ");
if (mode == HAHVAC::OffMode) {
Serial.println("off");
} else if (mode == HAHVAC::AutoMode) {
Serial.println("auto");
} else if (mode == HAHVAC::CoolMode) {
Serial.println("cool");
} else if (mode == HAHVAC::HeatMode) {
Serial.println("heat");
} else if (mode == HAHVAC::DryMode) {
Serial.println("dry");
} else if (mode == HAHVAC::FanOnlyMode) {
Serial.println("fan only");
}
}
void setup() {
Serial.begin(9600);
Serial.println("Starting...");
// Unique ID must be set!
byte mac[WL_MAC_ADDR_LENGTH];
WiFi.macAddress(mac);
device.setUniqueId(mac, sizeof(mac));
// connect to wifi
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500); // waiting for the connection
}
Serial.println();
Serial.println("Connected to the network");
// assign callbacks (optional)
hvac.setModes(HAHVAC::HeatMode + HAHVAC::OffMode);
hvac.onTargetTemperatureChanged(onTargetTemperatureChanged);
hvac.onModeChanged(onModeChanged);
// configure HVAC (optional)
hvac.setName("Home_Thermostat");
hvac.setMinTemp(16);
hvac.setMaxTemp(28);
hvac.setTempStep(0.5);
hvac.setCurrentTemperature(22.0);
hvac.setRetain(true);
mqtt.begin(BROKER_ADDR);
}
void loop() {
mqtt.loop();
if ((millis() - lastTempPublishAt) > 3000) {
hvac.setCurrentTemperature(lastTemp);
lastTempPublishAt = millis();
lastTemp += 0.5;
}
} I tested it for a while on NodeMCU and ESP-01 and all works perfectly fine. |
You can also enable debug mode of the library by uncommenting |
Hello @dawidchyrzynski, thank you for your support and work. Initializing ArduinoHA Maybe is a server config, or something on the HA server. Don't bother, is something I can live with :). Thank you again and have a nice evening! |
Hello Dawid!
Can you please add a sensor that transmit text message in payload.
I find very useful to update a status of a multi-switch to display text message instead of number.
For example if outside is "sunny", "cloudy" or "rainy", or for example in errors messages. Is helpful to have a error element that display the error in text format instead of number.
Thank you in advance!
The text was updated successfully, but these errors were encountered: