Giter Club home page Giter Club logo

ha_state_machine's People

Contributors

edalquist avatar trrevvorr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

trrevvorr

ha_state_machine's Issues

[FR] document behavior of undefined, internal (none) and self referencing triggers

I have my first state machine running. I noticed a warning is logged when a trigger if fired in a state that doesn't handle that trigger ( no transition defined for that trigger):

This error originated from a custom integration.

Logger: transitions.core
Source: custom_components/state_machine/sensor.py:188
Integration: State Machine
First occurred: 23:29:39 (1 occurrences)
Last logged: 23:29:39

Can't trigger event low from state HEATING!

That can be totally legit. For example, triggers that should not reset the timeout in a particular state. So I propose adding an option in the state machine settings (checkbox) to ignore triggers in states that don't handle them.

Alternative is to explicitly ignore triggers, with a keyword. So in the example below, the low and off triggers don't reset the timeout in the state ANTIWRINKLE. E.g.:

    "VENTING": {
      "high": "HEATING",
      "middle": "VENTING",
      "low": "ANTIWRINKLE",
      "off": "IDLE"
    },
    "ANTIWRINKLE": {
      "timeout": { "after": 300, "to": "IDLE" },
      "high": "HEATING",
      "middle": "VENTING",
      "low":  "_ignore_trigger_",
      "off":  "_ignore_trigger_"
    }

Best Eric

Question Automatic transitions after timeout

@edalquist

Hi Eric

Thanks for writing this very nice integration for HA. I especially like the addition of the timeout transition. So I consider to replace my current state machines with it.

Now my question, as I can't find it in the description and I can't read the Python code.

Let's presume I have a set transition defined to the same running state:

    "RUNNING": {
      "timeout": { "after": 120, "to": "DONE" },
      "stop": "IDLE",
      "set": "RUNNING"
    }

What happens to the timeout transition, when a set event emerges?
Will the timeout timer be reset back to 120 or will the original timer continue to count down?

I expect it will reset the timeout, as it re-enters the start, but I have to be sure ๐Ÿ˜‰

Thanks
Eric

[FR] support conditional transitions.

I made some awsome state machines with your integration. The need for substates emerged ๐Ÿ˜Ž

The transitions package has support for conditional transitions. It would be great to have that exposed in this integration.
The conditional transitions in the package then have a callback. For the integration that probably becomes a little too exotic.
My proposal is to allow for an optional condition parameter in the statemachine definition. Like this:

  "transitions": {
    "IDLE": {
      "on": "STARTING",
      "high": {"condition"="is_flammable", "to": "HEATING" },
      "high": {"condition"="not is_flammable", "to": "ALARM" },

   }

The condition is_flammable could be added as a boolean attribute on the state machine sensor. And you could provide a service to set / get these attributes.
Maybe a conditions section can be aded to initialyze these attributes:

  "state": {
    "status": "IDLE"
  },
  "conditions": {
    "is_flammable": true,
    ...

  },
  "transitions": {
    ...

This would add support for a kind of sub states.

Best Eric

Health errors in log since I installed this integration

Hi,

I copies the folder ha_state_machine, restarted and then added the integration with a sensor (using the example.json)
Since then I get these errors in my log:

Logger: homeassistant.helpers.integration_platform
Source: loader.py:855
First occurred: 15:16:11 (9 occurrences)
Last logged: 15:31:08

Unexpected error importing state_machine/system_health.py
Unexpected error importing state_machine/group.py
Unexpected error importing state_machine/cast.py
Unexpected error importing state_machine/hardware.py
Unexpected error importing state_machine/energy.py
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/integration_platform.py", line 50, in _async_process_single_integration_platform_component
    platform = integration.get_platform(platform_name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 838, in get_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 855, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custom_components.ha_state_machine-main.diagnostics'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.