separate Ha generic components from gateway specific ones
This commit is contained in:
parent
3b95a40728
commit
9796407ce8
@ -120,64 +120,6 @@ namespace Ha {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PollinSwitch : Switch {
|
|
||||||
const char* group;
|
|
||||||
unsigned char channel;
|
|
||||||
|
|
||||||
PollinSwitch(const char* name, const char* group, const unsigned char channel)
|
|
||||||
: Switch(name, Protocol_1::buildId(group, channel)), group(group), channel(channel) {
|
|
||||||
sprintf(commandTopic, "homeassistant/%s/rc-gateway/%s/set", type, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onCommand(const char* msg) override {
|
|
||||||
(String{ "ON" }.equals(msg)) ? mySwitch.switchOn(group, channel) : mySwitch.switchOff(group, channel);
|
|
||||||
publisher(stateTopic, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildConfig(JsonDocument& jsonDoc) override {
|
|
||||||
Switch::buildConfig(jsonDoc);
|
|
||||||
JsonObject device = jsonDoc["device"];
|
|
||||||
device["manufacturer"] = "Pollin";
|
|
||||||
}
|
|
||||||
|
|
||||||
void addToMap() override {
|
|
||||||
p1Switches.insert({string(id), this});
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EasyHomeSwitch : Switch {
|
|
||||||
unsigned long on[8] = {4326554, 4537114, 4767530, 4972714};
|
|
||||||
unsigned long off[8] = {4483146, 4626810, 4661562, 4819642};
|
|
||||||
|
|
||||||
EasyHomeSwitch(const char* name, const char* id, unsigned long on[4], unsigned long off[4])
|
|
||||||
: Switch(name, id) {
|
|
||||||
memcpy(&this->on[4], on, 4*sizeof(unsigned long));
|
|
||||||
memcpy(&this->off[4], off, 4*sizeof(unsigned long));
|
|
||||||
sprintf(commandTopic, "homeassistant/%s/rc-gateway/%s/set", type, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onCommand(const char* msg) override {
|
|
||||||
mySwitch.setProtocol(4);
|
|
||||||
String{ "ON" }.equals(msg) ? mySwitch.send(on[4], 24) : mySwitch.send(off[4], 24);
|
|
||||||
publisher(stateTopic, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildConfig(JsonDocument& jsonDoc) override {
|
|
||||||
Switch::buildConfig(jsonDoc);
|
|
||||||
JsonObject device = jsonDoc["device"];
|
|
||||||
device["manufacturer"] = "Intertek";
|
|
||||||
device["model"] = "Easy Home";
|
|
||||||
}
|
|
||||||
|
|
||||||
void addToMap() override {
|
|
||||||
for (int i = 0; i < 8; i++) {
|
|
||||||
onSwitches.insert({on[i], this});
|
|
||||||
offSwitches.insert({off[i], this});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Sensor : Component {
|
struct Sensor : Component {
|
||||||
const char* deviceClass;
|
const char* deviceClass;
|
||||||
const char* unitMeasure;
|
const char* unitMeasure;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <AsyncMqttClient.h>
|
#include <AsyncMqttClient.h>
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include "ha.h"
|
#include "devices.h"
|
||||||
|
|
||||||
|
|
||||||
#define MQTT_HOST IPAddress(192, 168, 5, 11)
|
#define MQTT_HOST IPAddress(192, 168, 5, 11)
|
||||||
@ -48,12 +48,12 @@ namespace Mqtt {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ha::Switch* switches[] = {
|
Ha::Switch* switches[] = {
|
||||||
(new Ha::PollinSwitch{"Meeting sensor", "00001", 1})->withArea("Dining room")->withStateTopic(),
|
(new PollinSwitch{"Meeting sensor", "00001", 1})->withArea("Dining room")->withStateTopic(),
|
||||||
(new Ha::PollinSwitch{"Fire Tv", "00001", 2})->withArea("Living room")->withStateTopic(),
|
(new PollinSwitch{"Fire Tv", "00001", 2})->withArea("Living room")->withStateTopic(),
|
||||||
(new Ha::PollinSwitch{"Diningroom player", "00001", 3})->withArea("Dining room")->withStateTopic(),
|
(new PollinSwitch{"Diningroom player", "00001", 3})->withArea("Dining room")->withStateTopic(),
|
||||||
(new Ha::PollinSwitch{"Train", "11111", 4})->withArea("Playroom")->withStateTopic(),
|
(new PollinSwitch{"Train", "11111", 4})->withArea("Playroom")->withStateTopic(),
|
||||||
(new Ha::EasyHomeSwitch{"FritzBox", "easy_home_a", (unsigned long[4]) { 4483136, 4626800, 4661552, 4819632 }, (unsigned long[4]) { 4326544, 4537104, 4767520, 4972704 }})->withArea("Basement")->withStateTopic(),
|
(new EasyHomeSwitch{"FritzBox", "easy_home_a", (unsigned long[4]) { 4483136, 4626800, 4661552, 4819632 }, (unsigned long[4]) { 4326544, 4537104, 4767520, 4972704 }})->withArea("Basement")->withStateTopic(),
|
||||||
(new Ha::EasyHomeSwitch{"Outside", "easy_home_b", (unsigned long[4]) { 4483140, 4626804, 4661556, 4819636 }, (unsigned long[4]) { 4326548, 4537108, 4767524, 4972708 }})->withArea("Basement")->withStateTopic()
|
(new EasyHomeSwitch{"Outside", "easy_home_b", (unsigned long[4]) { 4483140, 4626804, 4661556, 4819636 }, (unsigned long[4]) { 4326548, 4537108, 4767524, 4972708 }})->withArea("Basement")->withStateTopic()
|
||||||
};
|
};
|
||||||
|
|
||||||
void publishComponentConfig(Ha::Component& component) {
|
void publishComponentConfig(Ha::Component& component) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user