Introduction#
state
and state attributes
strongly depend on device type, features, communication protocol or way it's implemented in system
Most device share some common attributes
related to it's location or how device representation is displayed in user interface.
Depending on implementation some devices also share attributes related to hardware state or parameters that allow to monitor status of communication (ex. if request to change state was confirmed or not).
Example
common state attributes
{
"attributes": {
"area": "S5a",
"custom_ui_more_info": "more-info-picoides-light",
"custom_ui_state_card": "state-card-picoides-light",
"entity_id": "light.s5a_nema_06_01_2",
"friendly_name": "s5a_nema_06_01_2",
"icon": "mdi:lightbulb",
"last_set_state": "",
"last_update": "2018-12-13T11:23:41.192940+00:00",
"latitude": 52.174146,
"locked": false,
"longitude": 20.811675,
"platform": "picoides",
},
...
"state": "off"
}
Static attributes#
Attributes related to location or UI are usually defined in devices database during instance setup and are considered static.
Location#
state attributes related device location:
area
- object or string descriptive information about device locationstreet
latitude
- a geographic coordinate that specifies the north–south position of a point on the Earth's surface [wiki]longitude
- a geographic coordinate that specifies the east-west position of a point on the Earth's surface [wiki]
UI attributes#
state attributes directly related to user interface (UI)
friendly_name
- is human readable name or label of device used only in UIcustom_ui_more_info
custom_ui_state_card
icon
State extending attributes#
attributes listed below extend information stored by state
In some cases state
does not equal to real state of device. state
is a representation of desired or last known state and sometimes might differ from actual state of hardware device. If device losses communication with gateway or any other communication layer between the device and the instance it's state
might be misleading. To handle this problem additional attributes are provided in order to help investigate real situation.
status
- [int
] provides status code, example0
,1
,2
assumed_state
- [bool
] indicates not confirmed stateproblem
- [int
] provides error codestate_pending
- [bool
] set totrue
after request is sent to device but not yet confirmedsupported_features
- [bitfield
] Carries information features supported by device, ex. if light can be dimmed.last_set_state
- [json
] Fallback information on last sent requestlast_update
- [time UTC
] Time when device state object was changed or updated. Field is updated while handling response from device.locked
- [bool
] some device are set 'locked' based on given conditions. Iftrue
some requests (services) are not handled. Ex. light devices are locked during night, and cannot be turned off from UI or API