Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a02ae4106b | ||
|
|
6a411cea91 | ||
|
|
4ff72fdb07 | ||
|
|
93d1afd7e0 | ||
|
|
11bf31885e | ||
|
|
8b93ed6187 | ||
|
|
286f84fbb0 | ||
|
|
01a504f0ba | ||
|
|
c97fc433bc | ||
|
|
c5a78f998f | ||
|
|
eb106d7fe4 | ||
|
|
4ffa66c312 | ||
|
|
3ff545c6df | ||
|
|
458603e80c | ||
|
|
81dbc70b04 | ||
|
|
58ae700e0b | ||
|
|
399f55c57b | ||
|
|
900c40c8a1 | ||
|
|
860584ca79 | ||
|
|
d230ec6590 | ||
|
|
e0868fae9b | ||
|
|
59d3f9accd | ||
|
|
ee6dde688c | ||
|
|
e10e3e7c19 | ||
|
|
33756f1659 | ||
|
|
bd34c9fd81 | ||
|
|
590e110efa | ||
|
|
92b9392149 | ||
|
|
fced8328d7 | ||
|
|
ae301f25db | ||
|
|
fcc4de59c1 | ||
|
|
4587148d70 | ||
|
|
6c73814724 | ||
|
|
8c4009dc82 | ||
|
|
37de17749e | ||
|
|
d4c2548498 | ||
|
|
f889f18cd9 | ||
|
|
9abb91c3f9 | ||
|
|
76388df08c | ||
|
|
9626fafd2f | ||
|
|
71eb3a7c86 | ||
|
|
b9dd8bcad7 | ||
|
|
b1a5eca9a5 | ||
|
|
182a46cf92 | ||
|
|
e5c10104b8 | ||
|
|
541ea43435 | ||
|
|
62d4641097 | ||
|
|
153d5d479f | ||
|
|
7ea6821116 | ||
|
|
b1747ef487 | ||
|
|
ff3434612b | ||
|
|
57bb21e5ba | ||
|
|
18b6d83af2 |
@@ -0,0 +1,33 @@
|
|||||||
|
name: Test Runner
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
env:
|
||||||
|
GIT_SSL_NO_VERIFY: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test Job
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Echo message
|
||||||
|
run: |
|
||||||
|
echo "Hello from Gitea Actions!"
|
||||||
|
echo "Runner is working correctly!"
|
||||||
|
date
|
||||||
|
pwd
|
||||||
|
ls -la
|
||||||
|
|
||||||
|
- name: Test Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
|
||||||
|
- name: Check Python version
|
||||||
|
run: python --version
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
name: Update Version
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
|
||||||
|
env:
|
||||||
|
GIT_SSL_NO_VERIFY: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-version:
|
||||||
|
name: Update Version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.PAT_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pip install python-semantic-release
|
||||||
|
|
||||||
|
- name: Configure Git
|
||||||
|
run: |
|
||||||
|
git config --local user.email "actions@gitea.local"
|
||||||
|
git config --local user.name "Gitea Actions Bot"
|
||||||
|
|
||||||
|
- name: Run semantic-release
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.PAT_TOKEN }}
|
||||||
|
PYTHONHTTPSVERIFY: "0"
|
||||||
|
REQUESTS_CA_BUNDLE: ""
|
||||||
|
CURL_CA_BUNDLE: ""
|
||||||
|
run: |
|
||||||
|
echo "🚀 Запускаем semantic-release..."
|
||||||
|
semantic-release version
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
name: Create Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Create GitHub Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get tag info
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
TAG=${GITHUB_REF#refs/tags/}
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
TAG_MSG=$(git tag -l --format='%(contents)' $TAG 2>/dev/null || git log -1 --pretty=%B)
|
||||||
|
echo "message<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "$TAG_MSG" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create GitHub Release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
MSG="${{ steps.tag.outputs.message }}"
|
||||||
|
|
||||||
|
echo "🚀 Создаём релиз $TAG в GitHub..."
|
||||||
|
|
||||||
|
gh release create "$TAG" \
|
||||||
|
--title "Release $TAG" \
|
||||||
|
--notes "$MSG" \
|
||||||
|
--target main
|
||||||
|
|
||||||
|
echo "✅ Релиз создан!"
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
# CHANGELOG
|
||||||
|
|
||||||
|
<!-- version list -->
|
||||||
|
|
||||||
|
## v1.0.9 (2026-07-09)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Test
|
||||||
|
([`6a411ce`](https://192.168.200.208:3000/sirmrak/motion_light/commit/6a411cea91047e9714519dbb190d5d92252b024a))
|
||||||
|
|
||||||
|
|
||||||
|
## v1.0.8 (2026-07-09)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Тестовый релиз
|
||||||
|
([`11bf318`](https://192.168.200.208:3000/sirmrak/motion_light/commit/11bf31885eb113d02cf5c1558446a4671c1dc202))
|
||||||
|
|
||||||
|
|
||||||
|
## v1.0.7 (2026-07-09)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Тестим авторелиз
|
||||||
|
([`c5a78f9`](https://192.168.200.208:3000/sirmrak/motion_light/commit/c5a78f998fda972f0dfe4f938f0855d3c1d28aee))
|
||||||
|
|
||||||
|
|
||||||
|
## v1.0.6 (2026-07-09)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Тестовое исправление для автоматического релиза
|
||||||
|
([`58ae700`](https://192.168.200.208:3000/sirmrak/motion_light/commit/58ae700e0ba31b664222eccd96aaa17d30d2eff4))
|
||||||
|
|
||||||
|
|
||||||
|
## v1.0.5 (2026-07-09)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Configure semantic-release for Gitea with SSL
|
||||||
|
([`4587148`](https://192.168.200.208:3000/sirmrak/motion_light/commit/4587148d70e362fdd2a47523df0da959499fba2f))
|
||||||
|
|
||||||
|
- Disable SSL verification for semantic-release
|
||||||
|
([`ae301f2`](https://192.168.200.208:3000/sirmrak/motion_light/commit/ae301f25db468e56f9378582215b4dac6979722e))
|
||||||
|
|
||||||
|
- Release
|
||||||
|
([`59d3f9a`](https://192.168.200.208:3000/sirmrak/motion_light/commit/59d3f9accd5d2cb3b8e1ef4f403c7445e7da7b46))
|
||||||
|
|
||||||
|
- Release.yaml
|
||||||
|
([`bd34c9f`](https://192.168.200.208:3000/sirmrak/motion_light/commit/bd34c9fd81002974c08a6f349f0234b4e78353aa))
|
||||||
|
|
||||||
|
- Run Semantic Release
|
||||||
|
([`e10e3e7`](https://192.168.200.208:3000/sirmrak/motion_light/commit/e10e3e7c19c2da63289cd499cca5a5eacee22157))
|
||||||
|
|
||||||
|
- Test
|
||||||
|
([`e0868fa`](https://192.168.200.208:3000/sirmrak/motion_light/commit/e0868fae9ba86cd76eb070c5057960741eecba1e))
|
||||||
|
|
||||||
|
- Test commit for release
|
||||||
|
([`92b9392`](https://192.168.200.208:3000/sirmrak/motion_light/commit/92b93921498c7afd21d1dceec51518894c1efdcd))
|
||||||
|
|
||||||
|
- Изменил размер картинки
|
||||||
|
([`d4c2548`](https://192.168.200.208:3000/sirmrak/motion_light/commit/d4c25484981a33ab4455027ffb4ef693256aa414))
|
||||||
|
|
||||||
|
|
||||||
|
## v1.0.4 (2026-07-09)
|
||||||
|
|
||||||
|
|
||||||
|
## v1.0.3 (2026-07-08)
|
||||||
|
|
||||||
|
|
||||||
|
## v1.0.2 (2026-07-08)
|
||||||
|
|
||||||
|
|
||||||
|
## v1.0.1 (2026-07-08)
|
||||||
|
|
||||||
|
|
||||||
|
## v1.0.0 (2026-07-08)
|
||||||
|
|
||||||
|
- Initial Release
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
[English](README.md) | Русский
|
[English](README.md) | Русский
|
||||||
# <img src="custom_components/motion_light/brand/icon.png" width="64"> </img> Motion Light
|
# <img src="custom_components/motion_light/brand/icon.png" width="32"> </img> Motion Light
|
||||||
|
|
||||||
Умная интеграция для Home Assistant на основе конечного автомата (FSM) для управления освещением по датчикам движения, освещенности и ручным переключениям.
|
Умная интеграция для Home Assistant на основе конечного автомата (FSM) для управления освещением по датчикам движения, освещенности и ручным переключениям.
|
||||||
|
|
||||||
|
|||||||
@@ -44,4 +44,4 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
"""Handle options update."""
|
"""Handle options update."""
|
||||||
_LOGGER.info("Options updated, reloading Motion Light '%s'", entry.title)
|
_LOGGER.info("Options updated, reloading Motion Light '%s'", entry.title)
|
||||||
await hass.config_entries.async_reload(entry.entry_id)
|
await hass.config_entries.async_reload(entry.entry_id)
|
||||||
|
|||||||
@@ -46,5 +46,6 @@ STATE_ACTIVE = "active"
|
|||||||
STATE_OFF = "off"
|
STATE_OFF = "off"
|
||||||
STATE_MANUAL_ON = "manual_on"
|
STATE_MANUAL_ON = "manual_on"
|
||||||
STATE_MANUAL_OFF_COOLDOWN = "manual_off_cooldown"
|
STATE_MANUAL_OFF_COOLDOWN = "manual_off_cooldown"
|
||||||
|
STATE_FORCE_STOPPED = "force_stopped"
|
||||||
STATE_ERROR = "error"
|
STATE_ERROR = "error"
|
||||||
STATE_DISABLED = "disabled"
|
STATE_DISABLED = "disabled"
|
||||||
@@ -28,6 +28,7 @@ from .const import (
|
|||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_MANUAL_ON,
|
STATE_MANUAL_ON,
|
||||||
STATE_MANUAL_OFF_COOLDOWN,
|
STATE_MANUAL_OFF_COOLDOWN,
|
||||||
|
STATE_FORCE_STOPPED,
|
||||||
STATE_ERROR,
|
STATE_ERROR,
|
||||||
STATE_DISABLED,
|
STATE_DISABLED,
|
||||||
)
|
)
|
||||||
@@ -110,6 +111,9 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
attrs["main_sensors"] = self.main_sensors
|
attrs["main_sensors"] = self.main_sensors
|
||||||
attrs["extend_sensors"] = self.extend_sensors
|
attrs["extend_sensors"] = self.extend_sensors
|
||||||
attrs["lux_sensor"] = self.lux_sensor
|
attrs["lux_sensor"] = self.lux_sensor
|
||||||
|
attrs["force_stop_sensor"] = self.force_stop_sensor
|
||||||
|
attrs["force_stop_state"] = self.force_stop_state
|
||||||
|
attrs["force_stop_active"] = self._state == STATE_FORCE_STOPPED
|
||||||
attrs["active_main_sensors"] = self._get_active_main_sensors()
|
attrs["active_main_sensors"] = self._get_active_main_sensors()
|
||||||
attrs["active_extend_sensors"] = self._get_active_extend_sensors()
|
attrs["active_extend_sensors"] = self._get_active_extend_sensors()
|
||||||
attrs["lux_value"] = self._get_current_lux()
|
attrs["lux_value"] = self._get_current_lux()
|
||||||
@@ -154,8 +158,6 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
def set_manual_idle_timeout(self, value: float) -> None:
|
def set_manual_idle_timeout(self, value: float) -> None:
|
||||||
self.manual_idle_timeout = int(value)
|
self.manual_idle_timeout = int(value)
|
||||||
self.logger.info("Manual idle timeout set to %d sec", self.manual_idle_timeout)
|
self.logger.info("Manual idle timeout set to %d sec", self.manual_idle_timeout)
|
||||||
|
|
||||||
# Если таймер уже тикает, а мы изменили значение на 0, нужно его отменить
|
|
||||||
if self.manual_idle_timeout <= 0 and self._manual_idle_timer:
|
if self.manual_idle_timeout <= 0 and self._manual_idle_timer:
|
||||||
self.logger.info("Manual idle timeout set to 0, cancelling active timer")
|
self.logger.info("Manual idle timeout set to 0, cancelling active timer")
|
||||||
self._manual_idle_timer()
|
self._manual_idle_timer()
|
||||||
@@ -175,6 +177,15 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
self.logger.info("Switches: %s, Main sensors: %s, Extend sensors: %s, Lux: %s",
|
self.logger.info("Switches: %s, Main sensors: %s, Extend sensors: %s, Lux: %s",
|
||||||
self.switch_entities, self.main_sensors, self.extend_sensors, self.lux_sensor)
|
self.switch_entities, self.main_sensors, self.extend_sensors, self.lux_sensor)
|
||||||
|
|
||||||
|
# Проверяем состояние force_stop_sensor при старте
|
||||||
|
if self.force_stop_sensor:
|
||||||
|
force_stop_state_obj = self.hass.states.get(self.force_stop_sensor)
|
||||||
|
if force_stop_state_obj and force_stop_state_obj.state == self.force_stop_state:
|
||||||
|
self.logger.info("Force stop sensor is already in stop state at startup")
|
||||||
|
await self._update_state(STATE_FORCE_STOPPED)
|
||||||
|
await self._start_listening()
|
||||||
|
return
|
||||||
|
|
||||||
any_on = any(
|
any_on = any(
|
||||||
self.hass.states.get(s) and self.hass.states.get(s).state == "on"
|
self.hass.states.get(s) and self.hass.states.get(s).state == "on"
|
||||||
for s in self.switch_entities
|
for s in self.switch_entities
|
||||||
@@ -294,6 +305,11 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
self.logger.debug("Integration disabled, ignoring")
|
self.logger.debug("Integration disabled, ignoring")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# БЛОКИРОВЩИК: Игнорируем движение, если активна принудительная остановка
|
||||||
|
if self._state == STATE_FORCE_STOPPED:
|
||||||
|
self.logger.debug("Ignoring during force_stopped")
|
||||||
|
return
|
||||||
|
|
||||||
self.logger.debug("Main sensor ON by %s, current state: %s", triggered_by, self._state)
|
self.logger.debug("Main sensor ON by %s, current state: %s", triggered_by, self._state)
|
||||||
|
|
||||||
if self._state == STATE_MANUAL_OFF_COOLDOWN:
|
if self._state == STATE_MANUAL_OFF_COOLDOWN:
|
||||||
@@ -302,7 +318,6 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
|
|
||||||
if self._state == STATE_MANUAL_ON:
|
if self._state == STATE_MANUAL_ON:
|
||||||
self.logger.debug("During manual_on, resetting idle timer")
|
self.logger.debug("During manual_on, resetting idle timer")
|
||||||
# ИЗМЕНЕНИЕ: Сбрасываем таймер только если он включен (>0)
|
|
||||||
if self.manual_idle_timeout > 0:
|
if self.manual_idle_timeout > 0:
|
||||||
self._reset_manual_idle_timer()
|
self._reset_manual_idle_timer()
|
||||||
return
|
return
|
||||||
@@ -394,6 +409,11 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
self.logger.debug("Integration disabled, ignoring")
|
self.logger.debug("Integration disabled, ignoring")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# БЛОКИРОВЩИК: Игнорируем движение, если активна принудительная остановка
|
||||||
|
if self._state == STATE_FORCE_STOPPED:
|
||||||
|
self.logger.debug("Ignoring during force_stopped")
|
||||||
|
return
|
||||||
|
|
||||||
self.logger.debug("Extend sensor ON by %s, current state: %s", triggered_by, self._state)
|
self.logger.debug("Extend sensor ON by %s, current state: %s", triggered_by, self._state)
|
||||||
|
|
||||||
if self._state == STATE_IDLE:
|
if self._state == STATE_IDLE:
|
||||||
@@ -406,7 +426,6 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
|
|
||||||
if self._state == STATE_MANUAL_ON:
|
if self._state == STATE_MANUAL_ON:
|
||||||
self.logger.debug("During manual_on, resetting idle timer")
|
self.logger.debug("During manual_on, resetting idle timer")
|
||||||
# ИЗМЕНЕНИЕ: Сбрасываем таймер только если он включен (>0)
|
|
||||||
if self.manual_idle_timeout > 0:
|
if self.manual_idle_timeout > 0:
|
||||||
self._reset_manual_idle_timer()
|
self._reset_manual_idle_timer()
|
||||||
return
|
return
|
||||||
@@ -439,6 +458,11 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
"""Handle target switch state change."""
|
"""Handle target switch state change."""
|
||||||
if not self.respect_manual:
|
if not self.respect_manual:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# БЛОКИРОВЩИК: Игнорируем ручные переключения, если активна принудительная остановка
|
||||||
|
if self._state == STATE_FORCE_STOPPED:
|
||||||
|
self.logger.debug("Ignoring manual change during force_stopped")
|
||||||
|
return
|
||||||
|
|
||||||
new_state = event.data.get("new_state")
|
new_state = event.data.get("new_state")
|
||||||
old_state = event.data.get("old_state")
|
old_state = event.data.get("old_state")
|
||||||
@@ -485,9 +509,27 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
if not new_state:
|
if not new_state:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Если датчик перешел в блокирующее состояние
|
||||||
if new_state.state == self.force_stop_state:
|
if new_state.state == self.force_stop_state:
|
||||||
self.logger.info("Force stop triggered by %s", event.data.get("entity_id"))
|
self.logger.info("Force stop triggered by %s", event.data.get("entity_id"))
|
||||||
self.hass.async_create_task(self._force_stop())
|
self.hass.async_create_task(self._enter_force_stop())
|
||||||
|
# Если датчик вышел из блокирующего состояния
|
||||||
|
else:
|
||||||
|
self.logger.info("Force stop released by %s", event.data.get("entity_id"))
|
||||||
|
self.hass.async_create_task(self._exit_force_stop())
|
||||||
|
|
||||||
|
async def _enter_force_stop(self):
|
||||||
|
"""Enter force_stopped state."""
|
||||||
|
self.logger.info("Entering force_stopped state")
|
||||||
|
self._cancel_all_timers()
|
||||||
|
if self._state in (STATE_ON, STATE_DELAYING, STATE_ACTIVE, STATE_MANUAL_ON):
|
||||||
|
await self._turn_off_switches()
|
||||||
|
await self._update_state(STATE_FORCE_STOPPED)
|
||||||
|
|
||||||
|
async def _exit_force_stop(self):
|
||||||
|
"""Exit force_stopped state to idle."""
|
||||||
|
self.logger.info("Exiting force_stopped state")
|
||||||
|
await self._update_state(STATE_IDLE)
|
||||||
|
|
||||||
def _is_any_main_sensor_active(self) -> bool:
|
def _is_any_main_sensor_active(self) -> bool:
|
||||||
"""Check if any main sensor is currently in 'on' state."""
|
"""Check if any main sensor is currently in 'on' state."""
|
||||||
@@ -561,6 +603,11 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
LUX_CHECK_INTERVAL,
|
LUX_CHECK_INTERVAL,
|
||||||
self._check_lux_periodically,
|
self._check_lux_periodically,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.async_set_updated_data({
|
||||||
|
"state": self._state,
|
||||||
|
"attributes": self.attributes,
|
||||||
|
})
|
||||||
|
|
||||||
def _stop_lux_check_timer(self):
|
def _stop_lux_check_timer(self):
|
||||||
"""Stop periodic lux check timer."""
|
"""Stop periodic lux check timer."""
|
||||||
@@ -568,7 +615,10 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
self.logger.debug("Stopping lux check timer")
|
self.logger.debug("Stopping lux check timer")
|
||||||
self._lux_check_timer()
|
self._lux_check_timer()
|
||||||
self._lux_check_timer = None
|
self._lux_check_timer = None
|
||||||
|
self.async_set_updated_data({
|
||||||
|
"state": self._state,
|
||||||
|
"attributes": self.attributes,
|
||||||
|
})
|
||||||
@callback
|
@callback
|
||||||
def _check_lux_periodically(self, _=None):
|
def _check_lux_periodically(self, _=None):
|
||||||
"""Check lux periodically."""
|
"""Check lux periodically."""
|
||||||
@@ -658,11 +708,11 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
self.hass.async_create_task(self._update_state(STATE_IDLE))
|
self.hass.async_create_task(self._update_state(STATE_IDLE))
|
||||||
|
|
||||||
async def _turn_on_switches(self) -> None:
|
async def _turn_on_switches(self) -> None:
|
||||||
"""Turn on switches with our context."""
|
"""Turn on switches/lights with our context."""
|
||||||
ctx = Context(
|
ctx = Context(
|
||||||
id=f"motion_light_{self.entry.entry_id}_{dt_util.utcnow().timestamp()}"
|
id=f"motion_light_{self.entry.entry_id}_{dt_util.utcnow().timestamp()}"
|
||||||
)
|
)
|
||||||
self.logger.info("Turning ON switches: %s", self.switch_entities)
|
self.logger.info("Turning ON entities: %s", self.switch_entities)
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
"homeassistant",
|
"homeassistant",
|
||||||
"turn_on",
|
"turn_on",
|
||||||
@@ -671,11 +721,11 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def _turn_off_switches(self) -> None:
|
async def _turn_off_switches(self) -> None:
|
||||||
"""Turn off switches with our context."""
|
"""Turn off switches/lights with our context."""
|
||||||
ctx = Context(
|
ctx = Context(
|
||||||
id=f"motion_light_{self.entry.entry_id}_{dt_util.utcnow().timestamp()}"
|
id=f"motion_light_{self.entry.entry_id}_{dt_util.utcnow().timestamp()}"
|
||||||
)
|
)
|
||||||
self.logger.info("Turning OFF switches: %s", self.switch_entities)
|
self.logger.info("Turning OFF entities: %s", self.switch_entities)
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
"homeassistant",
|
"homeassistant",
|
||||||
"turn_off",
|
"turn_off",
|
||||||
@@ -686,7 +736,6 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
async def _enter_manual_on(self):
|
async def _enter_manual_on(self):
|
||||||
"""Enter manual_on state."""
|
"""Enter manual_on state."""
|
||||||
await self._update_state(STATE_MANUAL_ON)
|
await self._update_state(STATE_MANUAL_ON)
|
||||||
# ИЗМЕНЕНИЕ: Запускаем таймер только если он не отключен (не равен 0)
|
|
||||||
if self.manual_idle_timeout > 0:
|
if self.manual_idle_timeout > 0:
|
||||||
self._reset_manual_idle_timer()
|
self._reset_manual_idle_timer()
|
||||||
else:
|
else:
|
||||||
@@ -694,7 +743,6 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
|
|
||||||
def _reset_manual_idle_timer(self):
|
def _reset_manual_idle_timer(self):
|
||||||
"""Reset manual idle timer."""
|
"""Reset manual idle timer."""
|
||||||
# ИЗМЕНЕНИЕ: Защита от создания таймера при значении 0
|
|
||||||
if self.manual_idle_timeout <= 0:
|
if self.manual_idle_timeout <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -715,8 +763,8 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
self.hass.async_create_task(self._turn_off_switches_manual())
|
self.hass.async_create_task(self._turn_off_switches_manual())
|
||||||
|
|
||||||
async def _turn_off_switches_manual(self):
|
async def _turn_off_switches_manual(self):
|
||||||
"""Turn off switches in manual mode."""
|
"""Turn off switches/lights in manual mode."""
|
||||||
self.logger.info("Turning OFF switches (manual timeout): %s", self.switch_entities)
|
self.logger.info("Turning OFF entities (manual timeout): %s", self.switch_entities)
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
"homeassistant",
|
"homeassistant",
|
||||||
"turn_off",
|
"turn_off",
|
||||||
@@ -755,15 +803,11 @@ class MotionLightCoordinator(DataUpdateCoordinator):
|
|||||||
self._lux_cooldown_active = False
|
self._lux_cooldown_active = False
|
||||||
self._lux_cooldown_timer = None
|
self._lux_cooldown_timer = None
|
||||||
self.logger.info("Lux cooldown expired")
|
self.logger.info("Lux cooldown expired")
|
||||||
|
self.async_set_updated_data({
|
||||||
async def _force_stop(self):
|
"state": self._state,
|
||||||
"""Force stop — turn off switches."""
|
"attributes": self.attributes,
|
||||||
self.logger.info("Force stop called")
|
})
|
||||||
self._cancel_all_timers()
|
|
||||||
await self._turn_off_switches()
|
|
||||||
await self._update_state(STATE_OFF)
|
|
||||||
async_call_later(self.hass, 1, self._transition_to_idle)
|
|
||||||
|
|
||||||
def _cancel_all_timers(self):
|
def _cancel_all_timers(self):
|
||||||
"""Cancel all timers."""
|
"""Cancel all timers."""
|
||||||
if self._motion_detect_timer:
|
if self._motion_detect_timer:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"domain": "motion_light",
|
"domain": "motion_light",
|
||||||
"name": "Motion Light",
|
"name": "Motion Light",
|
||||||
"version": "1.0.1",
|
"version": "1.0.9",
|
||||||
"documentation": "https://github.com/sirmrak/motion_light",
|
"documentation": "https://github.com/sirmrak/motion_light",
|
||||||
"issue_tracker": "https://github.com/sirmrak/motion_light/issues",
|
"issue_tracker": "https://github.com/sirmrak/motion_light/issues",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from homeassistant.helpers.restore_state import RestoreEntity
|
|||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
CONF_LUX_SENSOR,
|
||||||
ENTITY_MOTION_FILTER,
|
ENTITY_MOTION_FILTER,
|
||||||
ENTITY_OFF_DELAY,
|
ENTITY_OFF_DELAY,
|
||||||
ENTITY_LUX_THRESHOLD,
|
ENTITY_LUX_THRESHOLD,
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class MotionLightStatusSensor(CoordinatorEntity, SensorEntity):
|
|||||||
"off": "mdi:lightbulb-off-outline",
|
"off": "mdi:lightbulb-off-outline",
|
||||||
"manual_on": "mdi:hand-back-left",
|
"manual_on": "mdi:hand-back-left",
|
||||||
"manual_off_cooldown": "mdi:timer-pause",
|
"manual_off_cooldown": "mdi:timer-pause",
|
||||||
|
"force_stopped": "mdi:stop-circle-outline",
|
||||||
"error": "mdi:alert-circle",
|
"error": "mdi:alert-circle",
|
||||||
"disabled": "mdi:lightbulb-off",
|
"disabled": "mdi:lightbulb-off",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,8 +55,25 @@
|
|||||||
"off": "Off",
|
"off": "Off",
|
||||||
"manual_on": "Manual on",
|
"manual_on": "Manual on",
|
||||||
"manual_off_cooldown": "Manual off cooldown",
|
"manual_off_cooldown": "Manual off cooldown",
|
||||||
|
"force_stopped": "Force stopped",
|
||||||
"error": "Error",
|
"error": "Error",
|
||||||
"disabled": "Disabled"
|
"disabled": "Disabled"
|
||||||
|
},
|
||||||
|
"attributes": {
|
||||||
|
"switch_entities": "Controlled switches",
|
||||||
|
"main_sensors": "Main triggers",
|
||||||
|
"extend_sensors": "Extend sensors",
|
||||||
|
"lux_sensor": "Illuminance sensor",
|
||||||
|
"force_stop_sensor": "Force stop sensor",
|
||||||
|
"force_stop_state": "Force stop state",
|
||||||
|
"force_stop_active": "Force stop active",
|
||||||
|
"active_main_sensors": "Active main triggers",
|
||||||
|
"active_extend_sensors": "Active extend sensors",
|
||||||
|
"lux_value": "Current illuminance",
|
||||||
|
"lux_cooldown_active": "Lux cooldown active",
|
||||||
|
"lux_check_active": "Lux check active",
|
||||||
|
"triggered_by": "Triggered by",
|
||||||
|
"last_motion_time": "Last motion time"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -55,8 +55,25 @@
|
|||||||
"off": "Выключено",
|
"off": "Выключено",
|
||||||
"manual_on": "Ручное включение",
|
"manual_on": "Ручное включение",
|
||||||
"manual_off_cooldown": "Пауза после ручного выкл.",
|
"manual_off_cooldown": "Пауза после ручного выкл.",
|
||||||
|
"force_stopped": "Принудительная остановка",
|
||||||
"error": "Ошибка",
|
"error": "Ошибка",
|
||||||
"disabled": "Отключено"
|
"disabled": "Отключено"
|
||||||
|
},
|
||||||
|
"attributes": {
|
||||||
|
"switch_entities": "Управляемые выключатели",
|
||||||
|
"main_sensors": "Главные триггеры",
|
||||||
|
"extend_sensors": "Датчики продления",
|
||||||
|
"lux_sensor": "Датчик освещённости",
|
||||||
|
"force_stop_sensor": "Датчик принудительной остановки",
|
||||||
|
"force_stop_state": "Состояние принудительной остановки",
|
||||||
|
"force_stop_active": "Принудительная остановка активна",
|
||||||
|
"active_main_sensors": "Активные главные триггеры",
|
||||||
|
"active_extend_sensors": "Активные датчики продления",
|
||||||
|
"lux_value": "Текущая освещённость",
|
||||||
|
"lux_cooldown_active": "Cooldown люкса активен",
|
||||||
|
"lux_check_active": "Проверка люкса активна",
|
||||||
|
"triggered_by": "Активировано",
|
||||||
|
"last_motion_time": "Последнее движение"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
[tool.semantic_release]
|
||||||
|
tag_format = "v{version}"
|
||||||
|
|
||||||
|
version_variables = [
|
||||||
|
"custom_components/motion_light/manifest.json:version",
|
||||||
|
]
|
||||||
|
|
||||||
|
commit_message = "chore(release): v{version}"
|
||||||
|
|
||||||
|
[tool.semantic_release.branches.main]
|
||||||
|
match = "(main|master)"
|
||||||
|
prerelease = false
|
||||||
|
|
||||||
|
[tool.semantic_release.commit_parser_options]
|
||||||
|
allowed_tags = ["feat", "fix", "docs", "style", "refactor", "perf", "test", "chore", "revert"]
|
||||||
|
minor_tags = ["feat"]
|
||||||
|
patch_tags = ["fix", "perf"]
|
||||||
Reference in New Issue
Block a user