Example #1
0
def core_to_hass_config(data,
                        config,
                        brightness=True,
                        rgb=True,
                        color_temp=True,
                        white_value=True):
    ret = mqtt.build_hass_config(data,
                                 'light',
                                 config,
                                 include_state=True,
                                 include_command=True,
                                 platform='mqtt_json')
    if ret is None:
        return None
    if brightness:
        ret['brightness'] = True
    if rgb:
        ret['rgb'] = True
    if color_temp:
        ret['color_temp'] = True
    if white_value:
        ret['white_value'] = True
    for effect in config.get(CONF_EFFECTS, []):
        ret["effect"] = True
        effects = ret.setdefault("effect_list", [])
        effects.append(next(x for x in effect.values())[CONF_NAME])
    return ret
Example #2
0
def core_to_hass_config(data, config):
    ret = mqtt.build_hass_config(data,
                                 'cover',
                                 config,
                                 include_state=True,
                                 include_command=True)
    if ret is None:
        return None
    return ret
Example #3
0
def core_to_hass_config(data, config):
    ret = mqtt.build_hass_config(data, 'fan', config, include_state=True, include_command=True)
    if ret is None:
        return None
    if CONF_OSCILLATION_OUTPUT in config:
        default = mqtt.get_default_topic_for(data, 'fan', config[CONF_NAME], 'oscillation/state')
        ret['oscillation_state_topic'] = config.get(CONF_OSCILLATION_STATE_TOPIC, default)
        default = mqtt.get_default_topic_for(data, 'fan', config[CONF_NAME], 'oscillation/command')
        ret['oscillation_command__topic'] = config.get(CONF_OSCILLATION_COMMAND_TOPIC, default)
    return ret
Example #4
0
def core_to_hass_config(data, config):
    ret = mqtt.build_hass_config(data,
                                 'sensor',
                                 config,
                                 include_state=True,
                                 include_command=False)
    if ret is None:
        return None
    if CONF_ICON in config:
        ret['icon'] = config[CONF_ICON]
    return ret
Example #5
0
def core_to_hass_config(data, config):
    ret = mqtt.build_hass_config(data,
                                 'binary_sensor',
                                 config,
                                 include_state=True,
                                 include_command=False)
    if ret is None:
        return None
    if CONF_DEVICE_CLASS in config:
        ret['device_class'] = config[CONF_DEVICE_CLASS]
    return ret
Example #6
0
def core_to_hass_config(data, config):
    ret = mqtt.build_hass_config(data,
                                 'switch',
                                 config,
                                 include_state=True,
                                 include_command=True)
    if ret is None:
        return None
    if CONF_ICON in config:
        ret['icon'] = config[CONF_ICON]
    if CONF_OPTIMISTIC in config:
        ret['optimistic'] = config[CONF_OPTIMISTIC]
    return ret
Example #7
0
def core_to_hass_config(data, config):
    ret = mqtt.build_hass_config(data, 'sensor', config, include_state=True, include_command=False)
    if ret is None:
        return None
    if CONF_UNIT_OF_MEASUREMENT in config:
        ret['unit_of_measurement'] = config[CONF_UNIT_OF_MEASUREMENT]
    if CONF_EXPIRE_AFTER in config:
        expire = config[CONF_EXPIRE_AFTER]
        if expire is not None:
            ret['expire_after'] = expire.total_seconds
    if CONF_ICON in config:
        ret['icon'] = config[CONF_ICON]
    return ret