-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for HVAC (#15) * remove HASwitch::triggerCallback method * fix typo in docs * HASwitch: simplify callback #define * work in progress: HVAC * replace local mqtt instances with singleton * device types optimization * cleanup * finished aux heating and away mode * wip: HVAC * finished HVAC implementation * HVAC implementation * add ifdefs for all HA components * wip: optimization * update readme * update examples * remove unused constructor from HAMqtt * update HAUtils * remove mqtt from constructors, fix compilation warnings * finished HVAC * add HVAC example, add changelog * update changelog, add documentation * Add support for icons in HASwitch and HASensor (#16) * add support for icon in HASwitch * add support for icon in HASensor * update changelog * add support for setting retain flag in HASwitch * Add support for text payload in HASensor (#17) * refactored HASensor * update changelog * fix sensor example * Add support for fans (HAFan) (#18) * finished basic implementation of the HAFan * add retain method to DeviceTypeSerializer * finished HAFan implementation * update HAHVAC * device types cleanup * add HAFan example * update changelog * update readme * update fan example * optimization, add support for ActionFeature in HVAC * Add support for MQTT LWT (#19) * add support for hostname in HAMqtt * add support for LWT and shared availability * minor fixes * added advanced availability example * update examples * update changelog * cleanup & bug fix * bump up version * minor improvements and fixes * update readme * add HAMqtt::onMessage method * Add support for covers (#28) * add HACovers * add cover example, update implementation * disable debug * update mqtt-events example * Add support for setting different prefix for non-discovery topics (#29) * add support for data prefix * cleanup * update comments and logs * update multi-state-button example * rename rexample from mqtt-events to mqtt-advanced * update changelog * update links in changelog * Home Assistant 2021.4.5 - MQTT upgrade (#33) * updae HAFan implementation * change lib version * update changelog * fix setSpeed method * update HAFan example * Separate uniqueId from name (#34) * rename name to uniqueId * remove legacy labels * update examples * rename isMyTopic to compareTopics * update changelog, rename name to uniqueId * Implement onBeforeStateChanged callback in HASwitch (#35) * add low latency mode to HASwitch * add onBeforeStateChanged callback to HASwitch * update readme * rename DEPRECATED macro * update advanced MQTT example
- Loading branch information
1 parent
15562fa
commit a4e50b7
Showing
40 changed files
with
977 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <Ethernet.h> | ||
#include <ArduinoHA.h> | ||
|
||
#define BROKER_ADDR IPAddress(192,168,0,17) | ||
|
||
byte mac[] = {0x00, 0x10, 0xFA, 0x6E, 0x38, 0x4A}; | ||
|
||
EthernetClient client; | ||
HADevice device(mac, sizeof(mac)); | ||
HAMqtt mqtt(client, device); | ||
HACover cover("my-cover"); // "my-cover" is unique ID of the cover. You should define your own ID. | ||
|
||
void onCoverCommand(HACover::CoverCommand cmd) { | ||
if (cmd == HACover::CommandOpen) { | ||
Serial.println("Command: Open"); | ||
cover.setState(HACover::StateOpening); | ||
} else if (cmd == HACover::CommandClose) { | ||
Serial.println("Command: Close"); | ||
cover.setState(HACover::StateClosing); | ||
} else if (cmd == HACover::CommandStop) { | ||
Serial.println("Command: Stop"); | ||
cover.setState(HACover::StateStopped); | ||
} | ||
|
||
// Available states: | ||
// HACover::StateClosed | ||
// HACover::StateClosing | ||
// HACover::StateOpen | ||
// HACover::StateOpening | ||
// HACover::StateStopped | ||
|
||
// You can also report position using setPosition() method | ||
} | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
Ethernet.begin(mac); | ||
|
||
cover.onCommand(onCoverCommand); | ||
cover.setName("My cover"); // optional | ||
// cover.setRetain(true); // optionally you can set retain flag | ||
|
||
mqtt.begin(BROKER_ADDR); | ||
} | ||
|
||
void loop() { | ||
Ethernet.maintain(); | ||
mqtt.loop(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <Ethernet.h> | ||
#include <ArduinoHA.h> | ||
|
||
#define BROKER_ADDR IPAddress(192,168,0,17) | ||
|
||
byte mac[] = {0x00, 0x10, 0xFA, 0x6E, 0x38, 0x4A}; | ||
|
||
EthernetClient client; | ||
HADevice device(mac, sizeof(mac)); | ||
HAMqtt mqtt(client, device); | ||
|
||
void onMqttMessage(const char* topic, const uint8_t* payload, uint16_t length) { | ||
// This callback is called when message from MQTT broker is received. | ||
// Please note that you should always verify if the message's topic is the one you expect. | ||
// For example: if (memcmp(topic, "myCustomTopic") == 0) { ... } | ||
|
||
Serial.print("New message on topic: "); | ||
Serial.println(topic); | ||
Serial.print("Data: "); | ||
Serial.println((const char*)payload); | ||
|
||
mqtt.publish("myPublishTopic", "hello"); | ||
} | ||
|
||
void onMqttConnected() { | ||
Serial.println("Connected to the broker!"); | ||
|
||
// You can subscribe to custom topic if you need | ||
mqtt.subscribe("myCustomTopic"); | ||
} | ||
|
||
void onMqttConnectionFailed() { | ||
Serial.println("Failed to connect to the broker!"); | ||
} | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
Ethernet.begin(mac); | ||
|
||
mqtt.onMessage(onMqttMessage); | ||
mqtt.onConnected(onMqttConnected); | ||
mqtt.onConnectionFailed(onMqttConnectionFailed); | ||
|
||
// If you use custom discovery prefix you can change it as following: | ||
// mqtt.setDiscoveryPrefix("customPrefix"); | ||
|
||
// If you want to change prefix only for non-discovery prefix: | ||
// mqtt.setDataPrefix("data"); | ||
|
||
mqtt.begin(BROKER_ADDR); | ||
} | ||
|
||
void loop() { | ||
Ethernet.maintain(); | ||
mqtt.loop(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.