FInal Version of Zephyr2
Includes abilty to change brightness of light through HomeKit as well as with button. However, the vent light is too unstable to do this perfectly, and increasing brightness by stepping through multiple decreases is annoying. To do: Create Zephyr3 without brightness control and test to see how it works in practice.
This commit is contained in:
parent
e5fd2a200f
commit
7987cdaf48
|
|
@ -91,6 +91,7 @@ struct DEV_ZephyrLight : Service::LightBulb {
|
|||
|
||||
if(resetLight){
|
||||
power->setVal(false);
|
||||
level->setVal(0);
|
||||
resetLight=false;
|
||||
}
|
||||
|
||||
|
|
@ -161,59 +162,7 @@ struct DEV_ZephyrFan : Service::Fan {
|
|||
} // button
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
struct DEV_ZephyrPower : Service::Switch {
|
||||
|
||||
uint32_t code;
|
||||
SpanCharacteristic *power;
|
||||
int buttonPin;
|
||||
|
||||
DEV_ZephyrPower(uint32_t code, int buttonPin, ServiceType mod=ServiceType::Regular) : Service::Switch(mod){
|
||||
|
||||
power=new Characteristic::On();
|
||||
new Characteristic::Name("Vent Power");
|
||||
this->code=code;
|
||||
this->buttonPin=buttonPin;
|
||||
|
||||
Serial.print("Configuring Zephyr Vent Hood Power 433MHz Transmitter with code: ");
|
||||
Serial.print(code,HEX);
|
||||
Serial.print("\n");
|
||||
new SpanButton(buttonPin);
|
||||
|
||||
}
|
||||
|
||||
StatusCode update(){
|
||||
|
||||
if(power->getNewVal()){
|
||||
LOG1("Activating Zephyr Vent Hood Power\n");
|
||||
transmitZephyr(code);
|
||||
}
|
||||
|
||||
return(StatusCode::OK);
|
||||
|
||||
} // update
|
||||
|
||||
void loop(){
|
||||
|
||||
if(power->getVal() && power->timeVal()>500){ // check that power is true, and that time since last modification is greater than 3 seconds
|
||||
LOG1("Resetting Zephyr Vent Hood Power Control\n"); // log message
|
||||
power->setVal(false); // set power to false
|
||||
}
|
||||
|
||||
} // loop
|
||||
|
||||
void button(int pin, boolean isLong) override {
|
||||
|
||||
LOG1("Activating Zephyr Vent Hood Power\n");
|
||||
transmitZephyr(code);
|
||||
power->setVal(true);
|
||||
|
||||
} // button
|
||||
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
void transmitZephyr(uint32_t code){
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@ void setup() {
|
|||
new DEV_Identify("Zephyr Fan","HomeSpan","ZVH-1","RF-Control","1.0",0);
|
||||
new DEV_ZephyrFan(0x51388,0x61398,16);
|
||||
|
||||
new SpanAccessory();
|
||||
new DEV_Identify("Zephyr Power","HomeSpan","ZVH-1","RF-Control","1.0",0);
|
||||
new DEV_ZephyrPower(0x61398,19);
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Reference in New Issue