server.events package¶
- This package implements socket.io event handlers.
namespace “/device” communicates with devices (listen for emitted data, forward commands from frontend)
namespace “/client” communicates with frontend (listen for command requests and send state updates)
Submodules¶
server.events.client module¶
server.events.device module¶
- server.events.device.on_command_state(device_id, data)[source]¶
Forward new default state of parameters of a command to client.
- server.events.device.on_connect(device)[source]¶
Accept authenticated connection and add device to sid database.
- server.events.device.on_entity(device_id, name_data)[source]¶
Handle new/updated entity emitted by a device.
server.events.update_frontend module¶
- server.events.update_frontend.emit_full_update(client_sid=None)[source]¶
Send full update to frontend. Includes all entities.
- Parameters:
client_sid – specify which client should recieve the update, or use client_sid=None to emit to all clients
- server.events.update_frontend.emit_update(**updated_entities)[source]¶
Send small update to frontend. Contains up to one entity of each type.
- Typical usage:
send a single child-entity when updating existing data
send a child-entity together with parent-entity (device) when sending a brand new child-entity
- Example:
update_partial(device=data_device, value={“value”: 3.2})