Coder Social home page Coder Social logo

plapointe6 / hamqttdevice Goto Github PK

View Code? Open in Web Editor NEW
41.0 41.0 15.0 27 KB

A library that provides tools to simplify MQTT discovery implementation for Home Assistant to your device.

License: GNU General Public License v3.0

C++ 100.00%
arduino arduino-library home-assistant iot iot-device

hamqttdevice's People

Contributors

doridian avatar leech001 avatar plapointe6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hamqttdevice's Issues

Error compiling library for Arduino Mega

I'm getting an error compiling the library for an Arduino Mega 2560.

Arduino\libraries\HAMqttDevice\src/HAMqttDevice.h:24:10: error: 'vector' in namespace 'std' does not name a template type
std::vector _configVars;
^~~~~~
Arduino\libraries\HAMqttDevice\src/HAMqttDevice.h:31:10: error: 'vector' in namespace 'std' does not name a template type
std::vector _attributes;
^~~~~~

status topic omitted from config payload when declaring multiple HAMqttDevices

When attempting to declare both a SWITCH and BINARY SENSOR in the same arduino sketch I noticed some strange behaviour - for the second device declared, the status topic (stat_t) was omitted from the config payload which appears to be causing homeassistant to fail to import the sensor. i.e. in the example below, garagedoorZSC wouldn't include stat_t even if I manually included garagedoorZSC.enableStateTopic();. If I reversed the following two lines, 'garagedoorZSC' would now include stat_t but 'garagedoor' would not.

HAMqttDevice garagedoor("11HS002 GD DEV", HAMqttDevice::SWITCH, "homeassistant");
HAMqttDevice garagedoorZSC("11ZSC002 DEV", HAMqttDevice::BINARY_SENSOR, "homeassistant");

Arduino code and outputs from serial for the two different cases:

HAMqttDevice garagedoor("11HS002 GD DEV", HAMqttDevice::SWITCH, "homeassistant");
HAMqttDevice garagedoorZSC("11ZSC002 DEV", HAMqttDevice::BINARY_SENSOR, "homeassistant");
<timestamp etc cutoff in serial monitor>Config topic : homeassistant/switch/11hs002_gd_dev/config
22:48:39.071 -> Config payload : {"~":"homeassistant/switch/11hs002_gd_dev","name":"11HS002 GD DEV","cmd_t":"~/cmd","stat_t":"~/state"}
22:48:39.106 -> Config topic : homeassistant/binary_sensor/11zsc002_dev/config
22:48:39.106 -> Config payload : {"~":"homeassistant/binary_sensor/11zsc002_dev","name":"11ZSC002 DEV"}
// Home Assitant device creation for MQTT discovery
HAMqttDevice garagedoorZSC("11ZSC002 DEV", HAMqttDevice::BINARY_SENSOR, "homeassistant");
HAMqttDevice garagedoor("11HS002 GD DEV", HAMqttDevice::SWITCH, "homeassistant");
<timestamp etc cutoff in serial monitor>Config topic : homeassistant/switch/11hs002_gd_dev/config
22:49:29.900 -> Config payload : {"~":"homeassistant/switch/11hs002_gd_dev","name":"11HS002 GD DEV","cmd_t":"~/cmd"}
22:49:29.900 -> Config topic : homeassistant/binary_sensor/11zsc002_dev/config
22:49:29.900 -> Config payload : {"~":"homeassistant/binary_sensor/11zsc002_dev","name":"11ZSC002 DEV","stat_t":"~/state"}

thanks, Dave

I'm not able to see my 'device/entitiy' in Home Assistant.

I'm using for the first time your library to simplify the management of the MQTT Discovery used by HA.
I have downloaded your "onoff_light" sample and loaded on my NodeMCU (with my settings for the ssid, password & c.)
I'm using Mosquitto broker Add on directly in HA, I have set the discovery_prefix to "/homeassistant" (I think the default of Home Assistant when it's not changed).
HAMqttDevice light("My Nice Lamp", HAMqttDevice::LIGHT, "/homeassistant");
I have also enabled the Serial to show some messages in the serial console:
client.enableDebuggingMessages();

The connection seems working in the correct way:

17:56:32.771 -> MQTT: Connecting to broker "192.168.1.15" with client name "my_sensor" ... (7.259000s) - ok. (7.366000s) 
17:56:32.913 -> MQTT: Subscribed to [/homeassistant/light/my_nice_lamp/cmd]
17:56:32.913 -> MQTT: Subscribed to [/homeassistant/status]
17:56:33.056 -> MQTT >> [/homeassistant/status] online
17:56:33.056 -> MQTT << [/homeassistant/light/my_nice_lamp/config] {"~":"/homeassistant/light/my_nice_lamp","name":"My Nice Lamp","cmd_t":"~/cmd","stat_t":"~/state","json_attr_t":"~/attr"}
17:56:38.065 -> MQTT << [/homeassistant/light/my_nice_lamp/state] OFF
17:56:38.065 -> MQTT << [/homeassistant/light/my_nice_lamp/attr] {"IP":"192.168.1.153"}

But I'm not able to see the my Device in the integration page (under MQTT, but I'm not sure if the lib works in this way).
I'm also not able to see my entity under the states page of "Developer tools" (I have searched the name 'my_nice_lamp').
The others devices that are using the MQTT are available under the MQTT integration (I have only Shelly devices actually), I think that the Mosquitto broker are configured correctly.

Have you additional test to suggest?

Thanks

Integrate an MQTT client

Your library is a good start. But why do you stop at the configuration only?
You could pass an MQTT client to the class and handle the messages and events too! eg. setAttribute(name,value), send(), etc.
Are you planning on this?

-Raomin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.