Example #1
0
 public static StateChange Map(this HassStateChangedEventData source, IHaContext haContext)
 {
     return(new StateChange(
                new Entity(haContext, source.EntityId),
                Map(source.OldState),
                Map(source.NewState)));
 }
Example #2
0
    internal void AddStateChangeEvent(HassState oldState, HassState newState)
    {
        var data = new HassStateChangedEventData
        {
            EntityId = newState.EntityId,
            NewState = newState,
            OldState = oldState
        };

        try
        {
            HomeAssistantEventMock.OnNext(
                new HassEvent
            {
                EventType   = "state_changed",
                DataElement = data.ToJsonElement()
            }
                );
        }
        catch (Exception e)
        {
            System.Console.WriteLine(e.Message);
        }
    }