-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
1 parent
4bc9f78
commit b2e7003
Showing
22 changed files
with
740 additions
and
295 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#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); | ||
|
||
// HAFan::SpeedsFeature enables support for setting different speeds of fan. | ||
// You can skip this argument if you don't need speed management. | ||
HAFan fan("ventilation", HAFan::SpeedsFeature); | ||
|
||
void onStateChanged(bool state) { | ||
Serial.print("State: "); | ||
Serial.println(state); | ||
} | ||
|
||
void onSpeedChanged(HAFan::Speed speed) { | ||
Serial.print("Speed: "); | ||
if (speed == HAFan::OffSpeed) { | ||
Serial.print("off"); | ||
} else if (speed == HAFan::LowSpeed) { | ||
Serial.print("low"); | ||
} else if (speed == HAFan::MediumSpeed) { | ||
Serial.print("medium"); | ||
} else if (speed == HAFan::HighSpeed) { | ||
Serial.print("high"); | ||
} | ||
} | ||
|
||
void setup() { | ||
// you don't need to verify return status | ||
Ethernet.begin(mac); | ||
|
||
// set device's details (optional) | ||
device.setName("Arduino"); | ||
device.setSoftwareVersion("1.0.0"); | ||
|
||
// configure fan (optional) | ||
// default speeds are: Off | Low | Medium | High | ||
fan.setSpeeds(HAFan::OffSpeed | HAFan::LowSpeed | HAFan::HighSpeed); | ||
fan.setName("Bathroom"); | ||
fan.setRetain(true); | ||
|
||
// handle fan states | ||
fan.onStateChanged(onStateChanged); | ||
fan.onSpeedChanged(onSpeedChanged); | ||
|
||
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
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
Oops, something went wrong.