I cannot seem to find an answer to my MQQT issue. I upgraded to Openhabian 2.5.0-1 Release Build with the built in MQQT broker from 2.4 and Mosquitto, now I am getting the following in my log:
==> /var/log/openhab2/openhab.log <==
2020-01-14 11:19:57.322 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'closed' not supported by type 'OpenCloseValue': No enum constant org.eclipse.smarthome.core.library.types.OpenClosedType.closed
This did work before upgrading to 2.5. The item is:
Contact MQQT_Basement_Door "Basement Door [MAP(door.map):%s]" <door> (gDoors, gPres_Basement, gBasement) [ "OpenState", "Door" ] { channel="mqtt:topic:1d0d7733:28f72894", alexa="ContactSensor", synonyms="Basement Door" }
This is the ino file for the ESP-01 door contact I made:
#include <PubSubClient.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
ADC_MODE(ADC_VCC);
//USER CONFIGURED SECTION START//
const char* ssid = "XXXXXX";
const char* password = "XXXXXX";
const char* mqtt_server = "10.0.1.25";
const int mqtt_port = 1883;
const char *mqtt_user = "openhabian";
const char *mqtt_pass = "XXXXX";
const char *mqtt_client_name = "Basement_Door"; // Client connections can't have the same connection name
const char *mqtt_topic = "House/Basement/Basement_Door";
IPAddress ip(10, 0, 1, 75);
IPAddress gateway(10, 0, 1, 1);
IPAddress subnet(255, 255, 255, 0);
//USER CONFIGURED SECTION END//
WiFiClient espClient;
PubSubClient client(espClient);
// Variables
bool boot = true;
char batteryVoltageMQTT[50];
//Functions
void setup_wifi()
{
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(50);
}
}
void reconnect()
{
while (!client.connected())
{
int battery_Voltage = ESP.getVcc() + 600;
String temp_str = String(battery_Voltage);
String mqttString = temp_str + "mV Replace Battery for basement door.";
mqttString.toCharArray(batteryVoltageMQTT, mqttString.length() + 1);
if (battery_Voltage <= 2900)
{
if (client.connect(mqtt_client_name, mqtt_user, mqtt_pass, mqtt_topic, 0, 1, batteryVoltageMQTT))
{
if(boot == true)
{
client.publish(mqtt_topic,"open");
boot = false;
}
}
else
{
ESP.restart();
}
}
if (battery_Voltage > 2900)
{
if (client.connect(mqtt_client_name, mqtt_user, mqtt_pass, mqtt_topic, 0, 1, "closed"))
{
if(boot == true)
{
client.publish(mqtt_topic,"open");
boot = false;
}
}
else
{
ESP.restart();
}
}
}
}
void setup()
{
setup_wifi();
client.setServer(mqtt_server, mqtt_port);
}
void loop()
{
if (boot == true)
{
reconnect();
}
else
{
ESP.deepSleep(0);
}
}
I use “open” and “closed” in the file, and by reading this error, do I have to re-flash the ESP-01 changing the ino file to “open” and “close”? Or is it possible to do a JSON transformation? If someone could point me in the right direction, I would appreciate it, MQQT is something that I can’t seem to wrap my head around.
~John