Skip to content

Commit be46cb8

Browse files
authored
feat!: rename stay mode to make the feature easier to understand (#176)
BREAKING CHANGE: Check the docs for new `stay_mode` configuration field and the name changes to the related services.
1 parent 505fa34 commit be46cb8

File tree

4 files changed

+23
-40
lines changed

4 files changed

+23
-40
lines changed

README.md

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Maintaining and improving this integration is very time consuming because of the
4040
[![donate gofundme](https://img.shields.io/badge/donate-GoFundMe-orange?style=flat-square)](https://gf.me/u/w62k93)
4141

4242
# :boom: Recent Breaking Changes :boom:
43+
* `v7.0.0` The configuration entry for stay mode was renamed from `stay` to `stay_mode`. Entity services have been renamed as well for consistency (see docs) [PR #176](https://github.com/danobot/entity-controller/pull/176), [Issue #143](https://github.com/danobot/entity-controller/issues/143).
4344
* `v6.0.0` introduces a breaking change if you are relying on the entities `friendly_name` in other automations. See [#153](https://github.com/danobot/entity-controller/pull/153). The release PR is [#156](https://github.com/danobot/entity-controller/pull/156).
4445

4546
# Features
@@ -128,14 +129,14 @@ motion_light_sun:
128129
end_time: sunrise + 00:30:00 # required
129130
```
130131

131-
# Stay on
132-
This simple option will keep EC in **active_stay_on** state indefinitely until the control entity is manually turned off.
132+
# Stay Mode
133+
This simple option will make EC give up control of entities after the initial trigger. EC will stay in `active_stay_on` state state indefinitely until the control entity is manually turned off.
133134
```yaml
134135
override_example:
135136
sensor: binary_sensor.lounge_motion
136137
entity: light.lounge_lamp
137138
delay: 5
138-
stay: true
139+
stay_mode: on
139140
```
140141

141142
### Overrides
@@ -354,7 +355,7 @@ motion_light:
354355
```
355356

356357
### Block Mode Time Restriction
357-
When `block_timeout` is defined, the controller will start a timer when the sensor is triggered and exit `blocked` state once the timeout is reached, thereby restricting the time that a controller can stay `blocked` mode. This is useful when you want the controller to turn off a light that was turned on manually.
358+
When `block_timeout` is defined, the controller will start a timer when the sensor is triggered and exit `blocked` state once the timeout is reached, thereby restricting the time that a controller can remain in `blocked` mode. This is useful when you want the controller to turn off a light that was turned on manually.
358359

359360
The state sequence is as follows:
360361

@@ -440,21 +441,21 @@ mtn_lounge:
440441

441442
The entity controller support a few services that can be used to extend the customization of the entity.
442443

443-
#### Stay
444+
#### Stay Mode
444445

445446
```yaml
446-
service: entity_controller.set_stay_on
447+
service: entity_controller.enable_stay_mode
447448
entity_id: entity_controller.motion
448449
```
449450

450-
This service takes an entity id and will set the stay flag to on
451+
This service takes an entity id and will enable stay mode which means that control entities will not be turned off once EC is triggered. All control entities must be manually turned off (or via other automations) before EC will return to `idle` state.
451452

452453
```yaml
453-
service: entity_controller.set_stay_off
454+
service: entity_controller.disable_stay_mode
454455
entity_id: entity_controller.motion
455456
```
456457

457-
This service takes an entity id and will clear the stay flag.
458+
This service takes an entity id and will disable stay mode. This does not transition EC to `idle` state if it is already in `active_stay_on` state. In this case you must turn off all entities manually.
458459

459460
**Note:** There is no attribute that exposes the stay flag state at this time.
460461

@@ -526,20 +527,6 @@ self.OVERRIDE_OFF_STATE = config.get("override_states_off", DEFAULT_OFF)
526527
self.STATE_ON_STATE = config.get("state_states_on", DEFAULT_ON)
527528
self.STATE_OFF_STATE = config.get("state_states_off", DEFAULT_OFF)
528529
```
529-
### Drawing State Machine Diagrams (not supported yet in `v2`)
530-
531-
You can generate state machine diagrams that update based on the state of the motion light. These produce a file in the file system that can be targeted by `file` based cameras.
532-
```yaml
533-
diagram_test:
534-
sensors:
535-
- binary_sensor.motion_detected
536-
entities:
537-
- light.tv_led
538-
draw: True # required, default is False
539-
image_path: '/conf/temp' # optional, default shown
540-
image_prefix: '/fsm_diagram_' # optional, default shown
541-
542-
```
543530

544531
### Customize which attribute changes are considered "manual control"
545532

custom_components/entity_controller/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ async def async_setup(hass, config):
353353
class EntityController(entity.Entity):
354354
from .entity_services import (
355355
async_entity_service_clear_block as async_clear_block,
356-
async_entitiy_service_set_stay_on as async_set_stay_on,
357-
async_entitiy_service_set_stay_off as async_set_stay_off,
356+
async_entity_service_enable_stay_mode as async_enable_stay_mode,
357+
async_entity_service_disable_stay_mode as async_disable_stay_mode,
358358
async_entity_service_set_night_mode as async_set_night_mode,
359359
)
360360

@@ -1083,7 +1083,7 @@ def config_other(self, config):
10831083
self.image_prefix = config.get("image_prefix", "/fsm_diagram_")
10841084
self.image_path = config.get("image_path", "/conf/temp")
10851085
self.backoff = config.get("backoff", False)
1086-
self.stay = config.get("stay", False)
1086+
self.stay = config.get("stay_mode", False)
10871087

10881088
if self.backoff:
10891089
self.log.debug("config_other :: setting up backoff. Using delay as initial backoff value.")

custom_components/entity_controller/const.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
# services
2323
SERVICE_CLEAR_BLOCK = "clear_block"
24-
SERVICE_SET_STAY_ON = "set_stay_on"
25-
SERVICE_SET_STAY_OFF = "set_stay_off"
24+
SERVICE_ENABLE_STAY_MODE = "enable_stay_mode"
25+
SERVICE_DISABLE_STAY_MODE = "disable_stay_mode"
2626
SERVICE_SET_NIGHT_MODE = "set_night_mode"
2727

2828
#configuration

custom_components/entity_controller/entity_services.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535

3636
from .const import (
3737
SERVICE_CLEAR_BLOCK,
38-
SERVICE_SET_STAY_ON,
39-
SERVICE_SET_STAY_OFF,
38+
SERVICE_ENABLE_STAY_MODE,
39+
SERVICE_DISABLE_STAY_MODE,
4040
SERVICE_SET_NIGHT_MODE,
4141
CONF_START_TIME,
4242
CONF_END_TIME,
@@ -49,8 +49,8 @@ def async_setup_entity_services(component: EntityComponent):
4949

5050
component.logger.debug("Setting up entity services")
5151
component.async_register_entity_service(SERVICE_CLEAR_BLOCK, {}, "async_clear_block")
52-
component.async_register_entity_service(SERVICE_SET_STAY_ON, {}, "async_set_stay_on")
53-
component.async_register_entity_service(SERVICE_SET_STAY_OFF, {}, "async_set_stay_off")
52+
component.async_register_entity_service(SERVICE_ENABLE_STAY_MODE, {}, "async_enable_stay_mode")
53+
component.async_register_entity_service(SERVICE_DISABLE_STAY_MODE, {}, "async_disable_stay_mode")
5454
component.async_register_entity_service(
5555
SERVICE_SET_NIGHT_MODE,
5656
{ vol.Optional(CONF_START_TIME): cv.string, vol.Optional(CONF_END_TIME): cv.string },
@@ -67,16 +67,12 @@ def async_entity_service_clear_block(self):
6767
self.model.log.debug("Clearing Blocked state")
6868
self.model.block_timer_expires()
6969

70-
def async_entitiy_service_set_stay_on(self):
71-
""" Changes the stay attribute with a custom value """
72-
73-
self.model.log.debug("Changing stay to on")
70+
def async_entity_service_enable_stay_mode(self):
71+
self.model.log.debug("Enable stay mode - Control entities will remain on until manually turned off")
7472
self.model.stay = True
7573

76-
def async_entitiy_service_set_stay_off(self):
77-
""" Changes the stay attribute with a custom value """
78-
79-
self.model.log.debug("Changing stay to off")
74+
def async_entity_service_disable_stay_mode(self):
75+
self.model.log.debug("Disable stay mode - Control entities will be managed by EC")
8076
self.model.stay = False
8177

8278
def async_entity_service_set_night_mode(self, start_time=None, end_time=None):

0 commit comments

Comments
 (0)