updating configuration
This commit is contained in:
@@ -67,11 +67,11 @@ def set_mode_by_co2(self, co2_level, is_night):
|
|||||||
# === Настраиваемые коэффициенты ===
|
# === Настраиваемые коэффициенты ===
|
||||||
CFG = {
|
CFG = {
|
||||||
'co2_auto_threshold': 600, # Ниже этого значения — auto_mode
|
'co2_auto_threshold': 600, # Ниже этого значения — auto_mode
|
||||||
'co2_min_control': 700, # Начало плавного роста скорости
|
'co2_min_control': 600, # Начало плавного роста скорости
|
||||||
'co2_max_control': 1200, # Максимальная скорость достигается здесь
|
'co2_max_control': 1000, # Максимальная скорость достигается здесь
|
||||||
'speed_min': 30, # Мин. скорость вентиляции
|
'speed_min': 1, # Мин. скорость вентиляции
|
||||||
'speed_max': 100, # Макс. скорость вентиляции
|
'speed_max': 100, # Макс. скорость вентиляции
|
||||||
'night_speed_factor': 0.75, # Коэффициент снижения скорости ночью
|
'night_speed_factor': 0.7, # Коэффициент снижения скорости ночью
|
||||||
'transition_smoothness': 0.3, # Плавность перехода (0-1)
|
'transition_smoothness': 0.3, # Плавность перехода (0-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,68 +103,12 @@ def set_mode_by_co2(self, co2_level, is_night):
|
|||||||
# === Плавный расчёт скорости ===
|
# === Плавный расчёт скорости ===
|
||||||
speed = calculate_speed(co2_level, CFG, is_night)
|
speed = calculate_speed(co2_level, CFG, is_night)
|
||||||
|
|
||||||
# Определение уровня для лога
|
|
||||||
if co2_level < CFG['co2_min_control']:
|
|
||||||
level_desc = 'good'
|
|
||||||
elif co2_level < CFG['co2_max_control'] * 0.7:
|
|
||||||
level_desc = 'moderate'
|
|
||||||
elif co2_level < CFG['co2_max_control']:
|
|
||||||
level_desc = 'high'
|
|
||||||
else:
|
|
||||||
level_desc = 'extremely high'
|
|
||||||
|
|
||||||
period = 'Night' if is_night else 'Day'
|
period = 'Night' if is_night else 'Day'
|
||||||
self.log('{}, CO2 is {}: {}. Set speed to {}.'.format(
|
self.log('{}, CO2 is {}. Set speed to {}.'.format(
|
||||||
period, level_desc, co2_level, speed))
|
period, co2_level, speed))
|
||||||
|
|
||||||
self.set_speed(speed)
|
self.set_speed(speed)
|
||||||
|
|
||||||
# def set_mode_by_co2(self, co2_level, is_night):
|
|
||||||
# self.heat_mode_by_time()
|
|
||||||
# if co2_level < 500:
|
|
||||||
# self.log('CO2 is fine: {}. Set auto mode.'.format(co2_level))
|
|
||||||
# self.auto_mode()
|
|
||||||
# if co2_level > 500 and co2_level < 800:
|
|
||||||
# if is_night:
|
|
||||||
# self.log('CO2 is normal: {}. Set night mode'.format(co2_level))
|
|
||||||
# self.night_mode()
|
|
||||||
# else:
|
|
||||||
# self.log('CO2 is normal: {}. Set auto mode.'.format(co2_level))
|
|
||||||
# self.auto_mode()
|
|
||||||
# return
|
|
||||||
# if co2_level > 800 and co2_level < 900:
|
|
||||||
# if is_night:
|
|
||||||
# self.log('Night, CO2 is high: {}. Set speed to 45.'.format(co2_level))
|
|
||||||
# self.set_speed(45)
|
|
||||||
# else:
|
|
||||||
# self.log('Day, CO2 is high: {}. Set speed to 65.'.format(co2_level))
|
|
||||||
# self.set_speed(65)
|
|
||||||
# return
|
|
||||||
# if co2_level > 900 and co2_level < 1000:
|
|
||||||
# if is_night:
|
|
||||||
# self.log('Night, CO2 is high: {}. Set speed to 65.'.format(co2_level))
|
|
||||||
# self.set_speed(65)
|
|
||||||
# else:
|
|
||||||
# self.log('Day, CO2 is high: {}. Set speed to 80.'.format(co2_level))
|
|
||||||
# self.set_speed(80)
|
|
||||||
# return
|
|
||||||
# if co2_level > 1000 and co2_level < 1200:
|
|
||||||
# if is_night:
|
|
||||||
# self.log('Night, CO2 is extremely high: {}. Set speed to 80.'.format(co2_level))
|
|
||||||
# self.set_speed(80)
|
|
||||||
# else:
|
|
||||||
# self.log('Day, CO2 is extremely high: {}. Set speed to 100.'.format(co2_level))
|
|
||||||
# self.set_speed(100)
|
|
||||||
# return
|
|
||||||
# if co2_level > 1200:
|
|
||||||
# if is_night:
|
|
||||||
# self.log('Night, CO2 is extremely high: {}. Set speed to 100.'.format(co2_level))
|
|
||||||
# self.set_speed(100)
|
|
||||||
# else:
|
|
||||||
# self.log('Day, CO2 is extremely high: {}. Set speed to 100.'.format(co2_level))
|
|
||||||
# self.set_speed(100)
|
|
||||||
# return
|
|
||||||
|
|
||||||
def set_speed(self, speed):
|
def set_speed(self, speed):
|
||||||
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
|
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class CoverByPresence(hass.Hass):
|
|||||||
if 'covers' not in self.args:
|
if 'covers' not in self.args:
|
||||||
self.error("Please provide covers in config!")
|
self.error("Please provide covers in config!")
|
||||||
return
|
return
|
||||||
|
self.log("Initializing CoverByPresence with covers: {}".format(self.args.get("covers")))
|
||||||
self.listen_event(self.away_mode, "away_mode")
|
self.listen_event(self.away_mode, "away_mode")
|
||||||
self.listen_event(self.return_home_mode, "return_home_mode")
|
self.listen_event(self.return_home_mode, "return_home_mode")
|
||||||
|
|
||||||
@@ -24,6 +25,27 @@ class CoverByPresence(hass.Hass):
|
|||||||
sunset_offset = int(self.args.get('sunset_offset', '0'))
|
sunset_offset = int(self.args.get('sunset_offset', '0'))
|
||||||
self.run_at_sunset(self.run_at_sunset_func, offset=sunset_offset)
|
self.run_at_sunset(self.run_at_sunset_func, offset=sunset_offset)
|
||||||
|
|
||||||
|
# Prepare cover door sensors mapping (optional)
|
||||||
|
self.cover_door_sensors = self.args.get("cover_door_sensors", {})
|
||||||
|
self.log("Cover door sensors mapping: {}".format(self.cover_door_sensors))
|
||||||
|
|
||||||
|
def is_cover_blocked(self, entity_id):
|
||||||
|
"""
|
||||||
|
Returns True if the cover has at least one associated door sensor
|
||||||
|
that is currently in 'on' (open) state.
|
||||||
|
"""
|
||||||
|
sensors = self.cover_door_sensors.get(entity_id, [])
|
||||||
|
if not sensors:
|
||||||
|
self.log("No door sensors configured for cover {}, treat as not blocked".format(entity_id))
|
||||||
|
return False
|
||||||
|
for sensor in sensors:
|
||||||
|
state = self.get_state(sensor)
|
||||||
|
self.log("Door sensor {} for cover {} state: {}".format(sensor, entity_id, state))
|
||||||
|
if state == "on":
|
||||||
|
self.log("Skip moving cover {} because door sensor {} is open".format(entity_id, sensor))
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def run_at_sunrise_func(self, kwargs):
|
def run_at_sunrise_func(self, kwargs):
|
||||||
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
|
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
|
||||||
self.log('execution is disabled.')
|
self.log('execution is disabled.')
|
||||||
@@ -38,6 +60,8 @@ class CoverByPresence(hass.Hass):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for entity_id in self.args["open_at_sunrise"]:
|
for entity_id in self.args["open_at_sunrise"]:
|
||||||
|
if self.is_cover_blocked(entity_id):
|
||||||
|
continue
|
||||||
self.log('opening cover {} at sunrise'.format(entity_id))
|
self.log('opening cover {} at sunrise'.format(entity_id))
|
||||||
self.turn_on_custom(entity_id)
|
self.turn_on_custom(entity_id)
|
||||||
|
|
||||||
@@ -49,6 +73,8 @@ class CoverByPresence(hass.Hass):
|
|||||||
self.log('no covers to close at sunset.')
|
self.log('no covers to close at sunset.')
|
||||||
return
|
return
|
||||||
for entity_id in self.args["close_at_sunset"]:
|
for entity_id in self.args["close_at_sunset"]:
|
||||||
|
if self.is_cover_blocked(entity_id):
|
||||||
|
continue
|
||||||
self.log('closing cover {} at sunset'.format(entity_id))
|
self.log('closing cover {} at sunset'.format(entity_id))
|
||||||
self.turn_off_custom(entity_id)
|
self.turn_off_custom(entity_id)
|
||||||
|
|
||||||
@@ -57,6 +83,8 @@ class CoverByPresence(hass.Hass):
|
|||||||
self.log('execution is disabled.')
|
self.log('execution is disabled.')
|
||||||
return
|
return
|
||||||
for entity_id in self.args["covers"]:
|
for entity_id in self.args["covers"]:
|
||||||
|
if self.is_cover_blocked(entity_id):
|
||||||
|
continue
|
||||||
self.turn_off_custom(entity_id)
|
self.turn_off_custom(entity_id)
|
||||||
|
|
||||||
def return_home_mode(self, event_id, event_args, kwargs):
|
def return_home_mode(self, event_id, event_args, kwargs):
|
||||||
@@ -68,6 +96,8 @@ class CoverByPresence(hass.Hass):
|
|||||||
return
|
return
|
||||||
entities = self.args["covers"]
|
entities = self.args["covers"]
|
||||||
for entity_id in entities:
|
for entity_id in entities:
|
||||||
|
if self.is_cover_blocked(entity_id):
|
||||||
|
continue
|
||||||
self.turn_on_custom(entity_id)
|
self.turn_on_custom(entity_id)
|
||||||
|
|
||||||
def turn_on_custom(self, entity_id):
|
def turn_on_custom(self, entity_id):
|
||||||
|
|||||||
@@ -24,6 +24,13 @@ cover_action:
|
|||||||
open_at_sunrise:
|
open_at_sunrise:
|
||||||
- cover.curtain_kitchen
|
- cover.curtain_kitchen
|
||||||
- cover.curtain_mainroom
|
- cover.curtain_mainroom
|
||||||
|
cover_door_sensors:
|
||||||
|
cover.curtain_bedroom:
|
||||||
|
- binary_sensor.door_bedroom_big_window_contact
|
||||||
|
cover.curtain_bedroom_balcony:
|
||||||
|
- binary_sensor.door_balcony_contact
|
||||||
|
cover.curtain_bedroom_bobbinet_balcony:
|
||||||
|
- binary_sensor.door_balcony_contact
|
||||||
global_dependencies:
|
global_dependencies:
|
||||||
- globals
|
- globals
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,9 @@ class TelegramInternetControl(hass.Hass):
|
|||||||
text = event_args['text']
|
text = event_args['text']
|
||||||
room = event_args['room']
|
room = event_args['room']
|
||||||
alice = event_args['entity_id']
|
alice = event_args['entity_id']
|
||||||
if text == self.block_command:
|
if text.lower() == self.block_command.lower():
|
||||||
self.handle_block_command('Monster1025')
|
self.handle_block_command('Monster1025')
|
||||||
|
self.say(alice, 'Интернет в детской отключен.')
|
||||||
|
|
||||||
def say(self, entity_id, command):
|
def say(self, entity_id, command):
|
||||||
self.log('command = {}'.format(command))
|
self.log('command = {}'.format(command))
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"pid": 106582, "version": 1, "ha_version": "2026.2.3", "start_ts": 1773083280.3675456}
|
{"pid": 67, "version": 1, "ha_version": "2026.2.3", "start_ts": 1774117247.3266375}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
yandex_station_intents:
|
yandex_station_intents:
|
||||||
intents:
|
intents:
|
||||||
Как дела: Все хорошо
|
Как дела: Все хорошо
|
||||||
Коля наказан: Отключаю интернет в детской
|
Коля наказан: Пробую отключить интернет в детской
|
||||||
Включи вентилятор:
|
Включи вентилятор:
|
||||||
execute_command: Поставь режим вентиляции на кондиционере в комнате {{ event.room }}
|
execute_command: Поставь режим вентиляции на кондиционере в комнате {{ event.room }}
|
||||||
Выключи вентилятор:
|
Выключи вентилятор:
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
template:
|
||||||
|
- sensor:
|
||||||
|
- unit_of_measurement: kWh
|
||||||
|
state: "{{ states('sensor.power_total') | float - 7072.7 | round(2) }}"
|
||||||
|
name: power_main_total
|
||||||
|
# 7072.7 - разница показаний.
|
||||||
|
|
||||||
|
- unit_of_measurement: ₽
|
||||||
|
state: "{{ states('sensor.power_monthly_t1') | float * 8.23 | round(2) }}"
|
||||||
|
name: power_monthly_cost_t1
|
||||||
|
|
||||||
|
- unit_of_measurement: ₽
|
||||||
|
state: "{{ states('sensor.power_monthly_t2') | float * 2.62 | round(2) }}"
|
||||||
|
name: power_monthly_cost_t2
|
||||||
|
|
||||||
|
- unit_of_measurement: ₽
|
||||||
|
state: "{{ states('sensor.power_monthly_t3') | float * 5.66 | round(2) }}"
|
||||||
|
name: power_monthly_cost_t3
|
||||||
|
|
||||||
|
- unit_of_measurement: ₽
|
||||||
|
state: "{{ (states('sensor.power_monthly_cost_t1') | float) + (states('sensor.power_monthly_cost_t2') | float) + (states('sensor.power_monthly_cost_t3') | float) | round(2) }}"
|
||||||
|
name: power_monthly_cost_total
|
||||||
@@ -97,27 +97,6 @@ modbus:
|
|||||||
scale: 0.01
|
scale: 0.01
|
||||||
unit_of_measurement: 'Hz'
|
unit_of_measurement: 'Hz'
|
||||||
|
|
||||||
sensor:
|
|
||||||
- platform: template
|
|
||||||
sensors:
|
|
||||||
power_main_total:
|
|
||||||
unit_of_measurement: 'kWh'
|
|
||||||
value_template: "{{ states('sensor.power_total') | float - 7072.7 | round(2) }}"
|
|
||||||
#7072.7 - разница показаний.
|
|
||||||
|
|
||||||
power_monthly_cost_t1:
|
|
||||||
unit_of_measurement: '₽'
|
|
||||||
value_template: "{{ states('sensor.power_monthly_t1') | float * 8.23 | round(2) }}"
|
|
||||||
power_monthly_cost_t2:
|
|
||||||
unit_of_measurement: '₽'
|
|
||||||
value_template: "{{ states('sensor.power_monthly_t2') | float * 2.62 | round(2) }}"
|
|
||||||
power_monthly_cost_t3:
|
|
||||||
unit_of_measurement: '₽'
|
|
||||||
value_template: "{{ states('sensor.power_monthly_t3') | float * 5.66 | round(2) }}"
|
|
||||||
power_monthly_cost_total:
|
|
||||||
unit_of_measurement: '₽'
|
|
||||||
value_template: "{{ states('sensor.power_monthly_cost_t1') | float + states('sensor.power_monthly_cost_t2') | float + states('sensor.power_monthly_cost_t3') | float | round(2) }}"
|
|
||||||
|
|
||||||
utility_meter:
|
utility_meter:
|
||||||
power_hourly:
|
power_hourly:
|
||||||
source: sensor.power_total
|
source: sensor.power_total
|
||||||
|
|||||||
Reference in New Issue
Block a user