import json import re def split_iu_entity(entity_id) -> list: if entity_id is not None: l = re.split(r"^(\d+)\.(\d+)\s(.*)$", state.get(entity_id)) if len(l) == 5: return l return None def convert_iu_entity(entity_id) -> str: if entity_id is not None: l = re.split(r"^(\d+)\.(\d+)\s(.*)$", state.get(entity_id)) if len(l) == 5: if l[2] == "0": l[2] = "m" else: l[2] = "z" + l[2] return f"binary_sensor.irrigation_unlimited_c{l[1]}_{l[2]}" return None def convert_iu_sequence(entity_id) -> list: if entity_id is not None: l = re.split(r"^(\d+)\.(\d+)\s(.*)$", state.get(entity_id)) if len(l) == 5: return f"binary_sensor.irrigation_unlimited_c{l[1]}_m", l[2] return None def convert_iu_sequence_zone(entity_id) -> list: value = state.get(entity_id) if value is not None: l = value.split(',') if len(l) == 1: try: value = [int(l[0])] except: value = None elif len(l) > 1: # Check all values are int's map(int, l) value = l else: value = None return value @service("irrigation_unlimited.list_config") def irrigation_unlimited_list_config(entity_id, section, first=None, controller_sequence_entity=None): """yaml name: List configuration description: Load up an input_select entity with Irrigation Unlimited config data fields: entity_id: description: An entity from the input_select domain example: input_select.irrigation_unlimited_entities required: true selector: entity: domain: input_select section: description: The type of list to load up example: entities required: true selector: select: options: - entities - sequences - sequence_zones first: description: The first item in the list example: