mirror of
https://github.com/nuttytree/ESPHome-Devices.git
synced 2024-08-30 18:12:19 +00:00
A bunch of misc changes (#32)
* Temporarily disable the heater * Shell of new garage fridge component * Core code should be mostly complete * Add power monitoring and freezer temp control * Wrap up core temperature management code * Add fixed InkBird component * The new fridge manages temp in the freezer better so we are able to greatly simplify things * Finish garage fridge * Misc changes Co-authored-by: Chris Nussbaum <chris.nussbaum@protolabs.com>
This commit is contained in:
parent
3c710571d4
commit
1b6d90d399
@ -9,7 +9,7 @@ from esphome.const import (
|
||||
UNIT_WATT,
|
||||
DEVICE_CLASS_POWER,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
ICON_POWER,
|
||||
ICON_FLASH,
|
||||
CONF_UPDATE_INTERVAL,
|
||||
)
|
||||
|
||||
@ -27,7 +27,7 @@ CONFIG_SCHEMA = light.BINARY_LIGHT_SCHEMA.extend(
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
icon=ICON_POWER,
|
||||
icon=ICON_FLASH,
|
||||
).extend(
|
||||
{
|
||||
cv.Optional(CONF_LIGHT_WATTAGE): cv.positive_float,
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/gpio.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/switch/switch.h"
|
||||
|
||||
|
@ -11,7 +11,7 @@ from esphome.const import (
|
||||
UNIT_WATT,
|
||||
DEVICE_CLASS_POWER,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
ICON_POWER,
|
||||
ICON_FLASH,
|
||||
CONF_UPDATE_INTERVAL,
|
||||
)
|
||||
|
||||
@ -47,7 +47,7 @@ CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend(
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
icon=ICON_POWER,
|
||||
icon=ICON_FLASH,
|
||||
).extend(
|
||||
{
|
||||
cv.Optional(CONF_DEVICE_WATTAGE): cv.positive_float,
|
||||
|
@ -45,7 +45,7 @@ void PumpSwitch::setup() {
|
||||
|
||||
void PumpSwitch::loop() {
|
||||
this->update_physical_switch_();
|
||||
this->check_current_();
|
||||
//this->check_current_();
|
||||
}
|
||||
|
||||
void PumpSwitch::update() {
|
||||
|
@ -9,7 +9,7 @@ from esphome.const import (
|
||||
UNIT_WATT,
|
||||
DEVICE_CLASS_POWER,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
ICON_POWER,
|
||||
ICON_FLASH,
|
||||
CONF_UPDATE_INTERVAL,
|
||||
)
|
||||
|
||||
@ -30,7 +30,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
icon=ICON_POWER,
|
||||
icon=ICON_FLASH,
|
||||
).extend(
|
||||
{
|
||||
cv.Optional(CONF_LIGHT_WATTAGE): cv.positive_float,
|
||||
|
@ -1,7 +1,7 @@
|
||||
from esphome.components import fan, sensor
|
||||
import esphome.config_validation as cv
|
||||
import esphome.codegen as cg
|
||||
from esphome.components.tuya import CONF_TUYA_ID, Tuya
|
||||
from esphome.components.tuya import tuya_ns, CONF_TUYA_ID, Tuya
|
||||
from esphome.const import (
|
||||
CONF_OUTPUT_ID,
|
||||
CONF_SWITCH_DATAPOINT,
|
||||
@ -19,8 +19,8 @@ CONF_DIMMER_DATAPOINT = "dimmer_datapoint"
|
||||
CONF_MAX_VALUE = "dimmer_max_value"
|
||||
CONF_FAN_WATTAGE = "fan_wattage"
|
||||
|
||||
tuya_ns = cg.esphome_ns.namespace("tuya")
|
||||
TuyaFan = tuya_ns.class_("TuyaDimmerAsFan", cg.Component)
|
||||
TuyaFan = tuya_ns.class_("TuyaDimmerAsFan", cg.PollingComponent, fan.Fan)
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
fan.FAN_SCHEMA.extend(
|
||||
@ -49,12 +49,10 @@ CONFIG_SCHEMA = cv.All(
|
||||
|
||||
async def to_code(config):
|
||||
parent = await cg.get_variable(config[CONF_TUYA_ID])
|
||||
state = await fan.create_fan_state(config)
|
||||
|
||||
var = cg.new_Pvariable(
|
||||
config[CONF_OUTPUT_ID], parent, state
|
||||
)
|
||||
var = cg.new_Pvariable(config[CONF_OUTPUT_ID], parent)
|
||||
await cg.register_component(var, config)
|
||||
await fan.register_fan(var, config)
|
||||
|
||||
cg.add(var.set_switch_id(config[CONF_SWITCH_DATAPOINT]))
|
||||
cg.add(var.set_dimmer_id(config[CONF_DIMMER_DATAPOINT]))
|
||||
|
@ -8,19 +8,10 @@ namespace tuya {
|
||||
static const char *const TAG = "tuya.fan";
|
||||
|
||||
void TuyaDimmerAsFan::setup() {
|
||||
auto traits = fan::FanTraits(false, false, false, 1);
|
||||
this->fan_->set_traits(traits);
|
||||
|
||||
this->parent_->register_listener(*this->switch_id_, [this](const TuyaDatapoint &datapoint) {
|
||||
auto call = this->fan_->make_call();
|
||||
call.set_state(datapoint.value_bool);
|
||||
call.perform();
|
||||
|
||||
if (this->fan_wattage_.has_value() && this->power_sensor_ != nullptr)
|
||||
{
|
||||
float power = datapoint.value_bool ? this->fan_wattage_.value() : 0.0f;
|
||||
this->power_sensor_->publish_state(power);
|
||||
}
|
||||
this->state = datapoint.value_bool;
|
||||
this->publish_state();
|
||||
this->update();
|
||||
});
|
||||
|
||||
this->parent_->register_listener(*this->dimmer_id_, [this](const TuyaDatapoint &datapoint) {
|
||||
@ -30,8 +21,6 @@ void TuyaDimmerAsFan::setup() {
|
||||
}
|
||||
});
|
||||
|
||||
this->fan_->add_on_state_callback([this]() { this->parent_->set_boolean_datapoint_value(*this->switch_id_, this->fan_->state); });
|
||||
|
||||
// Make sure we start at the max value
|
||||
this->parent_->set_integer_datapoint_value(*this->dimmer_id_, this->dimmer_max_value_);
|
||||
}
|
||||
@ -42,11 +31,16 @@ void TuyaDimmerAsFan::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, " Dimmer has datapoint ID %u", *this->dimmer_id_);
|
||||
}
|
||||
|
||||
void TuyaDimmerAsFan::control(const fan::FanCall &call) {
|
||||
this->parent_->set_boolean_datapoint_value(*this->switch_id_, *call.get_state());
|
||||
}
|
||||
|
||||
void TuyaDimmerAsFan::update()
|
||||
{
|
||||
if (this->fan_wattage_.has_value() && this->power_sensor_ != nullptr && this->fan_->state)
|
||||
if (this->fan_wattage_.has_value() && this->power_sensor_ != nullptr)
|
||||
{
|
||||
this->power_sensor_->publish_state(this->fan_wattage_.value());
|
||||
float power = this->state ? this->fan_wattage_.value() : 0.0f;
|
||||
this->power_sensor_->publish_state(power);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
namespace esphome {
|
||||
namespace tuya {
|
||||
|
||||
class TuyaDimmerAsFan : public PollingComponent {
|
||||
class TuyaDimmerAsFan : public PollingComponent, public fan::Fan {
|
||||
public:
|
||||
TuyaDimmerAsFan(Tuya *parent, fan::FanState *fan) : parent_(parent), fan_(fan) {}
|
||||
TuyaDimmerAsFan(Tuya *parent) : parent_(parent) {}
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void set_switch_id(uint8_t switch_id) { this->switch_id_ = switch_id; }
|
||||
@ -18,14 +18,16 @@ class TuyaDimmerAsFan : public PollingComponent {
|
||||
void set_dimmer_max_value(uint32_t max_value) { this->dimmer_max_value_ = max_value; }
|
||||
void set_fan_wattage(float fan_wattage) { this->fan_wattage_ = fan_wattage; }
|
||||
void set_power_sensor(sensor::Sensor *power_sensor) { this->power_sensor_ = power_sensor; }
|
||||
fan::FanTraits get_traits() override { return fan::FanTraits(false, false, false, 1); }
|
||||
void update() override;
|
||||
|
||||
protected:
|
||||
void control(const fan::FanCall &call) override;
|
||||
|
||||
Tuya *parent_;
|
||||
optional<uint8_t> switch_id_{};
|
||||
optional<uint8_t> dimmer_id_{};
|
||||
uint32_t dimmer_max_value_ = 255;
|
||||
fan::FanState *fan_;
|
||||
optional<float> fan_wattage_{};
|
||||
sensor::Sensor *power_sensor_;
|
||||
};
|
||||
|
@ -178,10 +178,8 @@ void TuyaLightPlus::handle_tuya_datapoint_(tuya::TuyaDatapoint datapoint)
|
||||
}
|
||||
}
|
||||
|
||||
// When the light is turned on at the switch the level of the Tuya device will stll be 0 so we set it to the current state value
|
||||
float brightness;
|
||||
this->state_->current_values_as_brightness(&brightness);
|
||||
this->parent_->set_integer_datapoint_value(*this->dimmer_id_, this->brightness_to_tuya_level_(brightness));
|
||||
// When the light is turned on at the switch the level of the Tuya device will stll be 0 so we set it to the default brightness or 1.0 if no default
|
||||
this->parent_->set_integer_datapoint_value(*this->dimmer_id_, this->brightness_to_tuya_level_(this->default_brightness_.value_or(1.0)));
|
||||
}
|
||||
|
||||
// Turned off with the physical button
|
||||
@ -199,15 +197,12 @@ void TuyaLightPlus::handle_tuya_datapoint_(tuya::TuyaDatapoint datapoint)
|
||||
this->tuya_state_is_on_ = datapoint.value_bool;
|
||||
this->state_->current_values.set_state(datapoint.value_bool);
|
||||
|
||||
// If the light was turned off we set the brightness of the Tuya device to 0 to prevent flashes during double clicks and if there is a
|
||||
// default brightness set the current brightness value to the default so that if it is turned on remotely it will be at the default value
|
||||
// If the light was turned off we set the brightness of the Tuya device to 0 to prevent flashes during double clicks and set the current
|
||||
// brightness value to the default value or 1.0 if no default so that if it is turned on remotely it will be at the default value
|
||||
if (!datapoint.value_bool)
|
||||
{
|
||||
this->parent_->set_integer_datapoint_value(*this->dimmer_id_, 0);
|
||||
if (this->default_brightness_.has_value())
|
||||
{
|
||||
this->state_->current_values.set_brightness(*this->default_brightness_);
|
||||
}
|
||||
this->state_->current_values.set_brightness(this->default_brightness_.value_or(1.0));
|
||||
}
|
||||
}
|
||||
else if (datapoint.id == *this->dimmer_id_)
|
||||
|
@ -1,7 +1,6 @@
|
||||
substitutions:
|
||||
device_id: basement_bathroom_light_fan
|
||||
device_name: Basement Bathroom Light and Fan
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
ip_address: !secret basement-bathroom-light-fan-ip
|
||||
ota_pwd: !secret basement-bathroom-light-fan-ota-pwd
|
||||
|
@ -1,7 +1,6 @@
|
||||
substitutions:
|
||||
device_id: basement_bathroom_sensor
|
||||
device_name: Basement Bathroom Sensor
|
||||
platform: ESP8266
|
||||
board: d1_mini
|
||||
ip_address: !secret basement-bathroom-sensor-ip
|
||||
ota_pwd: !secret basement-bathroom-sensor-ota-pwd
|
||||
|
@ -1,7 +1,6 @@
|
||||
substitutions:
|
||||
device_id: basement_bath_shower_light_heat
|
||||
device_name: Basement Bathroom Shower Light and Heater
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
ip_address: !secret basement-bathroom-shower-light-heater-ip
|
||||
ota_pwd: !secret basement-bathroom-shower-light-heater-ota-pwd
|
||||
|
@ -1,7 +1,6 @@
|
||||
substitutions:
|
||||
device_id: coffee_maker
|
||||
device_name: Coffee Maker
|
||||
platform: ESP8266
|
||||
board: nodemcuv2
|
||||
ip_address: !secret coffee-maker-ip
|
||||
ota_pwd: !secret coffee-maker-ota-pwd
|
||||
|
@ -29,4 +29,5 @@ light:
|
||||
power:
|
||||
id: power
|
||||
name: ${device_name} Power
|
||||
icon: mdi:flash
|
||||
light_wattage: 11.8
|
||||
|
@ -1,7 +1,6 @@
|
||||
substitutions:
|
||||
device_id: fire_pit_fountain
|
||||
device_name: Fire Pit and Fountain
|
||||
platform: ESP8266
|
||||
board: d1_mini
|
||||
ip_address: !secret fire-pit-fountain-ip
|
||||
ota_pwd: !secret fire-pit-fountain-ota-pwd
|
||||
|
11
devices/garage-lights.yaml
Normal file
11
devices/garage-lights.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
substitutions:
|
||||
device_id: garage-lights
|
||||
device_name: Garage Lights
|
||||
ip_address: !secret garage-lights-ip
|
||||
ota_pwd: !secret garage-lights-ota-pwd
|
||||
api_pwd: !secret garage-lights-api-pwd
|
||||
ap_wifi_pwd: !secret garage-lights-ap-pwd
|
||||
light_wattage: '378'
|
||||
|
||||
packages:
|
||||
shelly_1l: !include ../packages/shelly_1l.yaml
|
@ -1,12 +1,11 @@
|
||||
substitutions:
|
||||
device_id: master_bath_humidity_temp_sensor
|
||||
device_id: master-bath-hum-temp-sensor
|
||||
device_name: Master Bathroom Humidity and Temperature Sensor
|
||||
platform: ESP8266
|
||||
board: d1_mini
|
||||
ip_address: !secret master-bath-humidity-temp-sensor-ip
|
||||
ota_pwd: !secret master-bath-humidity-temp-sensor-ota-pwd
|
||||
api_pwd: !secret master-bath-humidity-temp-sensor-api-pwd
|
||||
ap_wifi_pwd: !secret master-bath-humidity-temp-sensor-ap-pwd
|
||||
ip_address: !secret master-bath-hum-temp-sensor-ip
|
||||
ota_pwd: !secret master-bath-hum-temp-sensor-ota-pwd
|
||||
api_pwd: !secret master-bath-hum-temp-sensor-api-pwd
|
||||
ap_wifi_pwd: !secret master-bath-hum-temp-sensor-ap-pwd
|
||||
|
||||
packages:
|
||||
device_base: !include ../packages/device_base.yaml
|
@ -1,7 +1,6 @@
|
||||
substitutions:
|
||||
device_id: master_bed
|
||||
device_name: Master Bed
|
||||
platform: ESP8266
|
||||
board: nodemcuv2
|
||||
ip_address: !secret master-bed-ip
|
||||
ota_pwd: !secret master-bed-ota-pwd
|
||||
|
@ -1,7 +1,6 @@
|
||||
substitutions:
|
||||
device_id: patio_lights
|
||||
device_id: patio-lights
|
||||
device_name: Patio Lights
|
||||
platform: ESP8266
|
||||
board: d1_mini
|
||||
ip_address: !secret patio-lights-ip
|
||||
ota_pwd: !secret patio-lights-ota-pwd
|
@ -1,7 +1,6 @@
|
||||
substitutions:
|
||||
device_id: pool_and_patio_lights
|
||||
device_name: Pool and Patio Lights
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
ip_address: !secret pool-and-patio-lights-ip
|
||||
ota_pwd: !secret pool-and-patio-lights-ota-pwd
|
||||
@ -77,6 +76,7 @@ light:
|
||||
sensor:
|
||||
- platform: total_daily_energy
|
||||
name: Pool Lights
|
||||
icon: mdi:flash
|
||||
power_id: pool_light_power
|
||||
method: left
|
||||
min_save_interval: 10min
|
||||
|
@ -1,7 +1,6 @@
|
||||
substitutions:
|
||||
device_id: pool_pumps
|
||||
device_name: Pool Pumps
|
||||
platform: ESP8266
|
||||
board: modwifi
|
||||
ip_address: !secret pool-pumps-ip
|
||||
ota_pwd: !secret pool-pumps-ota-pwd
|
||||
@ -97,11 +96,13 @@ sensor:
|
||||
pin: A0
|
||||
- platform: total_daily_energy
|
||||
name: "Pool Pump Total Daily Energy"
|
||||
icon: mdi:flash
|
||||
power_id: pool_pump_power
|
||||
method: left
|
||||
min_save_interval: 10min
|
||||
- platform: total_daily_energy
|
||||
name: "Pool Cleaner Total Daily Energy"
|
||||
icon: mdi:flash
|
||||
power_id: pool_cleaner_power
|
||||
method: left
|
||||
min_save_interval: 10min
|
||||
|
53
devices/scripture_of_the_day_test.yaml
Normal file
53
devices/scripture_of_the_day_test.yaml
Normal file
@ -0,0 +1,53 @@
|
||||
substitutions:
|
||||
platform: esp32
|
||||
board: esp32dev
|
||||
log_level: none
|
||||
wifi_ssid: secret_wifi_ssid
|
||||
wifi_password: secret_wifi_password
|
||||
device_id: scripture-of-the-day-test
|
||||
device_name: Scripture of the Day Test
|
||||
|
||||
esphome:
|
||||
name: ${device_id}
|
||||
platform: ${platform}
|
||||
board: ${board}
|
||||
arduino_version: latest
|
||||
build_path: ../build/${device_id}
|
||||
|
||||
packages:
|
||||
wifi: !include ../packages/wifi/wifi_dhcp.yaml
|
||||
logger: !include ../packages/logger/logger.yaml
|
||||
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../../esphome/esphome/components
|
||||
components: [ ds3231 ]
|
||||
|
||||
i2c:
|
||||
|
||||
ds3231:
|
||||
id: ds_rtc
|
||||
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_cmp
|
||||
timezone: America/Chicago
|
||||
- platform: ds3231
|
||||
id: rtc
|
||||
timezone: America/Chicago
|
||||
on_time_sync:
|
||||
then:
|
||||
- ds3231.set_alarm_1:
|
||||
id: ds_rtc
|
||||
alarm_type: match_day_of_month_hour_minute_second
|
||||
second: 1
|
||||
minute: 2
|
||||
hour: 3
|
||||
day: 4
|
||||
- ds3231.reset_alarm_1:
|
||||
id: ds_rtc
|
||||
- ds3231.set_alarm_2:
|
||||
id: ds_rtc
|
||||
alarm_type: every_minute
|
||||
- ds3231.reset_alarm_2: ds_rtc
|
@ -1,5 +1,4 @@
|
||||
substitutions:
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
|
||||
external_components:
|
||||
@ -24,6 +23,7 @@ espsense:
|
||||
sensor:
|
||||
- platform: total_daily_energy
|
||||
name: ${device_name}
|
||||
icon: mdi:flash
|
||||
power_id: power
|
||||
method: left
|
||||
min_save_interval: 10min
|
||||
|
@ -1,5 +1,4 @@
|
||||
substitutions:
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
|
||||
external_components:
|
||||
|
@ -1,5 +1,4 @@
|
||||
substitutions:
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
|
||||
external_components:
|
||||
|
69
packages/shelly_1l.yaml
Normal file
69
packages/shelly_1l.yaml
Normal file
@ -0,0 +1,69 @@
|
||||
substitutions:
|
||||
board: esp01_1m
|
||||
light_wattage: '0'
|
||||
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../components
|
||||
components: [ binary_light_with_power ]
|
||||
- source: github://cbpowell/ESPSense
|
||||
components: [ espsense ]
|
||||
|
||||
packages:
|
||||
base: !include device_base.yaml
|
||||
logger: !include logger/logger.yaml
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
id: on_button
|
||||
pin:
|
||||
number: GPIO4
|
||||
filters:
|
||||
- delayed_on_off: 50ms
|
||||
on_press:
|
||||
then:
|
||||
- light.turn_on: shelly_light
|
||||
- platform: gpio
|
||||
id: off_button
|
||||
pin:
|
||||
number: GPIO14
|
||||
filters:
|
||||
- delayed_on_off: 50ms
|
||||
on_press:
|
||||
then:
|
||||
- light.turn_off: shelly_light
|
||||
|
||||
espsense:
|
||||
plugs:
|
||||
- name: ${device_name}
|
||||
power_sensor: light_power
|
||||
voltage: 120
|
||||
|
||||
light:
|
||||
- platform: binary_light_with_power
|
||||
id: shelly_light
|
||||
name: ${device_name}
|
||||
output: shelly_relay
|
||||
power:
|
||||
id: light_power
|
||||
name: ${device_name} Power
|
||||
light_wattage: ${light_wattage}
|
||||
|
||||
output:
|
||||
- platform: gpio
|
||||
pin: GPIO5
|
||||
id: shelly_relay
|
||||
|
||||
sensor:
|
||||
- platform: total_daily_energy
|
||||
name: ${device_name}
|
||||
power_id: light_power
|
||||
method: left
|
||||
min_save_interval: 10min
|
||||
|
||||
status_led:
|
||||
pin: GPIO0
|
||||
|
||||
time:
|
||||
- platform: homeassistant
|
@ -1,6 +1,5 @@
|
||||
# Model TGWF115PQM
|
||||
substitutions:
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
restore_mode: ALWAYS_ON
|
||||
|
||||
@ -14,7 +13,7 @@ packages:
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
id: button
|
||||
id: power_button
|
||||
pin:
|
||||
number: GPIO3
|
||||
inverted: True
|
||||
@ -49,6 +48,7 @@ sensor:
|
||||
update_interval: 2s
|
||||
- platform: total_daily_energy
|
||||
name: ${device_name}
|
||||
icon: mdi:flash
|
||||
power_id: power
|
||||
method: trapezoid
|
||||
min_save_interval: 10min
|
||||
@ -61,6 +61,7 @@ status_led:
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: ${device_name} Power Switch
|
||||
icon: mdi:power
|
||||
id: relay
|
||||
pin: GPIO14
|
||||
restore_mode: ${restore_mode}
|
||||
|
72
packages/topgreener_smart_plug_as_fan.yaml
Normal file
72
packages/topgreener_smart_plug_as_fan.yaml
Normal file
@ -0,0 +1,72 @@
|
||||
# Model TGWF115PQM
|
||||
substitutions:
|
||||
board: esp01_1m
|
||||
restore_mode: ALWAYS_ON
|
||||
|
||||
external_components:
|
||||
- source: github://cbpowell/ESPSense
|
||||
components: [ espsense ]
|
||||
|
||||
packages:
|
||||
base: !include device_base.yaml
|
||||
logger: !include logger/logger_no_serial.yaml
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
id: button
|
||||
pin:
|
||||
number: GPIO3
|
||||
inverted: True
|
||||
on_press:
|
||||
then:
|
||||
- switch.toggle: relay
|
||||
|
||||
espsense:
|
||||
plugs:
|
||||
- name: ${device_name}
|
||||
power_sensor: power
|
||||
voltage: 120
|
||||
|
||||
fan:
|
||||
- platform: binary
|
||||
name: ${device_name}
|
||||
output: relay
|
||||
|
||||
output:
|
||||
- platform: gpio
|
||||
name: ${device_name}
|
||||
id: relay
|
||||
pin: GPIO14
|
||||
|
||||
sensor:
|
||||
- platform: hlw8012
|
||||
sel_pin:
|
||||
number: GPIO12
|
||||
inverted: True
|
||||
cf_pin: GPIO04
|
||||
cf1_pin: GPIO5
|
||||
current_resistor: "0.0019"
|
||||
voltage_divider: "2150"
|
||||
current:
|
||||
name: ${device_name} Current
|
||||
unit_of_measurement: A
|
||||
power:
|
||||
id: power
|
||||
name: ${device_name} Power
|
||||
unit_of_measurement: W
|
||||
initial_mode: CURRENT
|
||||
change_mode_every: 4294967295
|
||||
update_interval: 2s
|
||||
- platform: total_daily_energy
|
||||
name: ${device_name}
|
||||
power_id: power
|
||||
method: trapezoid
|
||||
min_save_interval: 10min
|
||||
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO13
|
||||
inverted: False
|
||||
|
||||
time:
|
||||
- platform: homeassistant
|
Loading…
Reference in New Issue
Block a user