Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.shelly.utils Namespace Reference

Classes

class  ShellyReceiver
 

Functions

None async_create_issue_unsupported_firmware (HomeAssistant hass, ConfigEntry entry)
 
None async_remove_orphaned_entities (HomeAssistant hass, str config_entry_id, str mac, str platform, Iterable[str] keys, str|None key_suffix=None)
 
None async_remove_shelly_entity (HomeAssistant hass, str domain, str unique_id)
 
None async_remove_shelly_rpc_entities (HomeAssistant hass, str domain, str mac, list[str] keys)
 
int brightness_to_percentage (int brightness)
 
str get_block_channel_name (BlockDevice device, Block|None block)
 
int get_block_device_sleep_period (dict[str, Any] settings)
 
str get_block_entity_name (BlockDevice device, Block|None block, str|None description=None)
 
list[tuple[str, str]] get_block_input_triggers (BlockDevice device, Block block)
 
COAP get_coap_context (HomeAssistant hass)
 
int get_device_entry_gen (ConfigEntry entry)
 
datetime get_device_uptime (float uptime, datetime|None last_uptime)
 
str get_host (str host)
 
int get_http_port (MappingProxyType[str, Any] data)
 
bool get_info_auth (dict[str, Any] info)
 
int get_info_gen (dict[str, Any] info)
 
str get_model_name (dict[str, Any] info)
 
int get_number_of_channels (BlockDevice device, Block block)
 
str|None get_release_url (int gen, str model, bool beta)
 
str get_rpc_channel_name (RpcDevice device, str key)
 
int get_rpc_device_wakeup_period (dict[str, Any] status)
 
str get_rpc_entity_name (RpcDevice device, str key, str|None description=None)
 
list[tuple[str, str]] get_rpc_input_triggers (RpcDevice device)
 
list[int] get_rpc_key_ids (dict[str, Any] keys_dict, str key)
 
list[str] get_rpc_key_instances (dict[str, Any] keys_dict, str key)
 
str|None get_rpc_ws_url (HomeAssistant hass)
 
list[tuple[str, str]] get_shbtn_input_triggers ()
 
list[str] get_virtual_component_ids (dict[str, Any] config, str platform)
 
WsServer get_ws_context (HomeAssistant hass)
 
bool is_block_channel_type_light (dict[str, Any] settings, int channel)
 
bool is_block_momentary_input (dict[str, Any] settings, Block block, bool include_detached=False)
 
bool is_rpc_channel_type_light (dict[str, Any] config, int channel)
 
bool is_rpc_momentary_input (dict[str, Any] config, dict[str, Any] status, str key)
 
bool is_rpc_thermostat_internal_actuator (dict[str, Any] status)
 
bool is_rpc_thermostat_mode (int ident, dict[str, Any] status)
 
bool is_rpc_wifi_stations_disabled (dict[str, Any] config, dict[str, Any] _status, str key)
 
str|None mac_address_from_name (str name)
 
int percentage_to_brightness (int percentage)
 
None update_device_fw_info (HomeAssistant hass, BlockDevice|RpcDevice shellydevice, ConfigEntry entry)
 

Detailed Description

Shelly helpers functions.

Function Documentation

◆ async_create_issue_unsupported_firmware()

None homeassistant.components.shelly.utils.async_create_issue_unsupported_firmware ( HomeAssistant  hass,
ConfigEntry   entry 
)
Create a repair issue if the device runs an unsupported firmware.

Definition at line 463 of file utils.py.

◆ async_remove_orphaned_entities()

None homeassistant.components.shelly.utils.async_remove_orphaned_entities ( HomeAssistant  hass,
str  config_entry_id,
str  mac,
str  platform,
Iterable[str]  keys,
str | None   key_suffix = None 
)
Remove orphaned entities.

Definition at line 548 of file utils.py.

◆ async_remove_shelly_entity()

None homeassistant.components.shelly.utils.async_remove_shelly_entity ( HomeAssistant  hass,
str  domain,
str   unique_id 
)
Remove a Shelly entity.

Definition at line 65 of file utils.py.

◆ async_remove_shelly_rpc_entities()

None homeassistant.components.shelly.utils.async_remove_shelly_rpc_entities ( HomeAssistant  hass,
str  domain,
str  mac,
list[str]   keys 
)
Remove RPC based Shelly entity.

Definition at line 512 of file utils.py.

◆ brightness_to_percentage()

int homeassistant.components.shelly.utils.brightness_to_percentage ( int  brightness)
Convert brightness level to percentage.

Definition at line 438 of file utils.py.

◆ get_block_channel_name()

str homeassistant.components.shelly.utils.get_block_channel_name ( BlockDevice  device,
Block | None  block 
)
Get name based on device and channel name.

Definition at line 114 of file utils.py.

◆ get_block_device_sleep_period()

int homeassistant.components.shelly.utils.get_block_device_sleep_period ( dict[str, Any]  settings)
Return the device sleep period in seconds or 0 for non sleeping devices.

Definition at line 281 of file utils.py.

◆ get_block_entity_name()

str homeassistant.components.shelly.utils.get_block_entity_name ( BlockDevice  device,
Block | None  block,
str | None   description = None 
)
Naming for block based switch and sensors.

Definition at line 100 of file utils.py.

◆ get_block_input_triggers()

list[tuple[str, str]] homeassistant.components.shelly.utils.get_block_input_triggers ( BlockDevice  device,
Block   block 
)
Return list of input triggers for block.

Definition at line 189 of file utils.py.

◆ get_coap_context()

COAP homeassistant.components.shelly.utils.get_coap_context ( HomeAssistant  hass)
Get CoAP context to be used in all Shelly Gen1 devices.

Definition at line 221 of file utils.py.

◆ get_device_entry_gen()

int homeassistant.components.shelly.utils.get_device_entry_gen ( ConfigEntry  entry)
Return the device generation from config entry.

Definition at line 353 of file utils.py.

◆ get_device_uptime()

datetime homeassistant.components.shelly.utils.get_device_uptime ( float  uptime,
datetime | None  last_uptime 
)
Return device uptime string, tolerate up to 5 seconds deviation.

Definition at line 176 of file utils.py.

◆ get_host()

str homeassistant.components.shelly.utils.get_host ( str  host)
Get the device IP address or hostname.

Definition at line 497 of file utils.py.

◆ get_http_port()

int homeassistant.components.shelly.utils.get_http_port ( MappingProxyType[str, Any]  data)
Get port from config entry data.

Definition at line 492 of file utils.py.

◆ get_info_auth()

bool homeassistant.components.shelly.utils.get_info_auth ( dict[str, Any]  info)
Return true if device has authorization enabled.

Definition at line 298 of file utils.py.

◆ get_info_gen()

int homeassistant.components.shelly.utils.get_info_gen ( dict[str, Any]  info)
Return the device generation from shelly info.

Definition at line 303 of file utils.py.

◆ get_model_name()

str homeassistant.components.shelly.utils.get_model_name ( dict[str, Any]  info)
Return the device model name.

Definition at line 308 of file utils.py.

◆ get_number_of_channels()

int homeassistant.components.shelly.utils.get_number_of_channels ( BlockDevice  device,
Block  block 
)
Get number of channels for block type.

Definition at line 76 of file utils.py.

◆ get_release_url()

str | None homeassistant.components.shelly.utils.get_release_url ( int  gen,
str  model,
bool  beta 
)
Return release URL or None.

Definition at line 454 of file utils.py.

◆ get_rpc_channel_name()

str homeassistant.components.shelly.utils.get_rpc_channel_name ( RpcDevice  device,
str  key 
)
Get name based on device and channel name.

Definition at line 316 of file utils.py.

◆ get_rpc_device_wakeup_period()

int homeassistant.components.shelly.utils.get_rpc_device_wakeup_period ( dict[str, Any]  status)
Return the device wakeup period in seconds or 0 for non sleeping devices.

Definition at line 293 of file utils.py.

◆ get_rpc_entity_name()

str homeassistant.components.shelly.utils.get_rpc_entity_name ( RpcDevice  device,
str  key,
str | None   description = None 
)
Naming for RPC based switch and sensors.

Definition at line 341 of file utils.py.

◆ get_rpc_input_triggers()

list[tuple[str, str]] homeassistant.components.shelly.utils.get_rpc_input_triggers ( RpcDevice  device)
Return list of input triggers for RPC device.

Definition at line 400 of file utils.py.

◆ get_rpc_key_ids()

list[int] homeassistant.components.shelly.utils.get_rpc_key_ids ( dict[str, Any]  keys_dict,
str  key 
)
Return list of key ids for RPC device from a dict.

Definition at line 369 of file utils.py.

◆ get_rpc_key_instances()

list[str] homeassistant.components.shelly.utils.get_rpc_key_instances ( dict[str, Any]  keys_dict,
str  key 
)
Return list of key instances for RPC device from a dict.

Definition at line 358 of file utils.py.

◆ get_rpc_ws_url()

str | None homeassistant.components.shelly.utils.get_rpc_ws_url ( HomeAssistant  hass)
Return the RPC websocket URL.

Definition at line 585 of file utils.py.

◆ get_shbtn_input_triggers()

list[tuple[str, str]] homeassistant.components.shelly.utils.get_shbtn_input_triggers ( )
Return list of input triggers for SHBTN models.

Definition at line 215 of file utils.py.

◆ get_virtual_component_ids()

list[str] homeassistant.components.shelly.utils.get_virtual_component_ids ( dict[str, Any]  config,
str  platform 
)
Return a list of virtual component IDs for a platform.

Definition at line 528 of file utils.py.

◆ get_ws_context()

WsServer homeassistant.components.shelly.utils.get_ws_context ( HomeAssistant  hass)
Get websocket server context to be used in all Shelly Gen2 devices.

Definition at line 274 of file utils.py.

◆ is_block_channel_type_light()

bool homeassistant.components.shelly.utils.is_block_channel_type_light ( dict[str, Any]  settings,
int  channel 
)
Return true if block channel appliance type is set to light.

Definition at line 381 of file utils.py.

◆ is_block_momentary_input()

bool homeassistant.components.shelly.utils.is_block_momentary_input ( dict[str, Any]  settings,
Block  block,
bool   include_detached = False 
)
Return true if block input button settings is set to a momentary type.

Definition at line 143 of file utils.py.

◆ is_rpc_channel_type_light()

bool homeassistant.components.shelly.utils.is_rpc_channel_type_light ( dict[str, Any]  config,
int  channel 
)
Return true if rpc channel consumption type is set to light.

Definition at line 387 of file utils.py.

◆ is_rpc_momentary_input()

bool homeassistant.components.shelly.utils.is_rpc_momentary_input ( dict[str, Any]  config,
dict[str, Any]  status,
str   key 
)
Return true if rpc input button settings is set to a momentary type.

Definition at line 374 of file utils.py.

◆ is_rpc_thermostat_internal_actuator()

bool homeassistant.components.shelly.utils.is_rpc_thermostat_internal_actuator ( dict[str, Any]  status)
Return true if the thermostat uses an internal relay.

Definition at line 395 of file utils.py.

◆ is_rpc_thermostat_mode()

bool homeassistant.components.shelly.utils.is_rpc_thermostat_mode ( int  ident,
dict[str, Any]  status 
)
Return True if 'thermostat:<IDent>' is present in the status.

Definition at line 523 of file utils.py.

◆ is_rpc_wifi_stations_disabled()

bool homeassistant.components.shelly.utils.is_rpc_wifi_stations_disabled ( dict[str, Any]  config,
dict[str, Any]  _status,
str   key 
)
Return true if rpc all WiFi stations are disabled.

Definition at line 482 of file utils.py.

◆ mac_address_from_name()

str | None homeassistant.components.shelly.utils.mac_address_from_name ( str  name)
Convert a name to a mac address.

Definition at line 448 of file utils.py.

◆ percentage_to_brightness()

int homeassistant.components.shelly.utils.percentage_to_brightness ( int  percentage)
Convert percentage to brightness level.

Definition at line 443 of file utils.py.

◆ update_device_fw_info()

None homeassistant.components.shelly.utils.update_device_fw_info ( HomeAssistant  hass,
BlockDevice | RpcDevice  shellydevice,
ConfigEntry   entry 
)
Update the firmware version information in the device registry.

Definition at line 419 of file utils.py.