Add Ability to create finite statemachine and define transitions

It will be useful to have a sensor which can change states based on transition or home assistant events
Currently, we do not have a simple way of achieving this as we need individual automations to trigger the transitions and use input_select to maintain the state and combine that with other entity states to do the necessary transitions.

Triggered template sensors have been a thing for a while now.

https://www.home-assistant.io/integrations/template/#trigger-based-template-binary-sensors-buttons-numbers-selects-and-sensors

This will still need triggers to account for the initial states:

For Example:

Awake - > On Bed + Night → Going to Bed
Going to Bed → Phone charger connected → Sleeping
Sleeping → In Bed + Phone Charger Disconnected → Waking up
Waking up → Off Bed + Morning → Awake

Yes, all that can be templated in the trigger and/or state.