Exemple #1
0
        /// <summary>
        ///     Converts HassState to EntityState
        /// </summary>
        /// <param name="hassState"></param>
        /// <returns></returns>
        public static EntityState Map(this HassState hassState)
        {
            var entityState = new EntityState
            {
                EntityId = hassState.EntityId,
                State    = hassState.State,

                LastUpdated = hassState.LastUpdated,
                LastChanged = hassState.LastChanged,
                Context     = ContextMapper.Map(hassState.Context)
            };

            MapAttributes(entityState, hassState);

            return(entityState);
        }
Exemple #2
0
        /// <summary>
        ///     Converts HassState to EntityState
        /// </summary>
        /// <param name="hassState">HassState object to map</param>
        public static EntityState Map(this HassState hassState)
        {
            _ = hassState ??
                throw new NetDaemonArgumentNullException(nameof(hassState));
            var entityState = new EntityState
            {
                EntityId = hassState.EntityId,
                State    = hassState.State,

                LastUpdated = hassState.LastUpdated,
                LastChanged = hassState.LastChanged,
                Context     = ContextMapper.Map(hassState.Context)
            };

            MapAttributes(entityState, hassState);

            return(entityState);
        }