-
Notifications
You must be signed in to change notification settings - Fork 58
-
Howdy! Is it possible to use pyscript to build entirely new entities, similar to how template sensors/entities work? The built-in templating engine is... less than optimal. I believe I can already do almost all the needed bits with pyscript -- I can define triggers, and within that trigger function I can set state values. But I need a new synthetic entity to set state on; any suggestions on how I can create that?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 3 replies
-
I just saw #129 -- it looks like what I'm looking for. But is it required, or is there a less-elegant workaround possible before this is merged?
Beta Was this translation helpful? Give feedback.
All reactions
-
Okay, answering my own question. state.persist
works perfectly well for this use case. Sample in case someone else comes looking for this:
POWER_ATTR = { "unit_of_measurement": "kW", "device_class": "power" }
state.persist('pyscript.tesla_card_grid_to_house', default_value="0", default_attributes=POWER_ATTR)
@state_trigger('sensor.powerwall_load_now', ...)
def recalc_power():
...
pyscript.tesla_card_grid_to_house = 123.0
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 3
-
so, I guess when you use auto_entities (hacs), you can automactly add this to lovelace (when you create the names in a smart way :) )
Beta Was this translation helpful? Give feedback.
All reactions
-
You should mark this Discussion as "Answered".
Beta Was this translation helpful? Give feedback.