State Case Class

class sgio.model.StateCase(case: dict = {}, states: dict = {})

Bases: object

addState(name: str, state: State | None = None, data=None, entity_id=None, loc_type='')

Add a state to the StateCase object.

Parameters:
name : str

State name.

state : State, optional

State object. Default is None.

data : list or dict, optional

Data to be added. Default is None.

entity_id : int, optional

Entity ID. Default is None.

loc_type : str, optional

Location type. Default is ‘’.

at(locs: Iterable, state_name=None)

A function returning all states with data at a list of given locations.

Parameters:
locs : list

List of locations.

state_name : str or list, optional

State name(s). Default is None.

Returns:

A copy of the StateCase object with the states at the given locations.

Return type:

StateCase

getState(name)

Get state by name.

Parameters:
name : str

State name.

Returns:

State object.

Return type:

State

toDictionary()

Convert the StateCase object to a dictionary.

Returns:

A dictionary representation of the StateCase object.

{
    'case': case,
    'states': {
        'name1': state1.toDictionary(),
        'name2': state2.toDictionary(),
        ...
    }
}

Return type:

dict