ced3cd2616332af50bf9a8a4a7241aae017c34e8,homeassistant/components/sensor/neurio_energy.py,,setup_platform,#Any#Any#Any#Any#,36

Before Change


    api_secret = config.get(CONF_API_SECRET)
    sensor_id = config.get(CONF_SENSOR_ID)

    if not sensor_id:
        import neurio
        neurio_tp = neurio.TokenProvider(key=api_key, secret=api_secret)
        neurio_client = neurio.Client(token_provider=neurio_tp)
        user_info = neurio_client.get_user_information()
        _LOGGER.warning("Sensor ID auto-detected, set api_sensor_id: "%s"",
                        user_info["locations"][0]["sensors"][0]["sensorId"])
        sensor_id = user_info["locations"][0]["sensors"][0]["sensorId"]

    add_devices([NeurioEnergy(api_key, api_secret, name, sensor_id)])


class NeurioEnergy(Entity):

After Change


    api_secret = config.get(CONF_API_SECRET)
    sensor_id = config.get(CONF_SENSOR_ID)

    data = NeurioData(api_key, api_secret, sensor_id)

    @Throttle(MIN_TIME_BETWEEN_DAILY_UPDATES)
    def update_daily():
        Update the daily power usage.
        data.get_daily_usage()

    @Throttle(MIN_TIME_BETWEEN_ACTIVE_UPDATES)
    def update_active():
        Update the active power usage.
        data.get_active_power()

    update_daily()
    update_active()

    // Active power sensor
    add_devices([NeurioEnergy(data, ACTIVE_NAME, ACTIVE_TYPE, update_active)])
    // Daily power sensor
    add_devices([NeurioEnergy(data, DAILY_NAME, DAILY_TYPE, update_daily)])


class NeurioData(object):
    Stores data retrieved from Neurio sensor.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: home-assistant/home-assistant
Commit Name: ced3cd2616332af50bf9a8a4a7241aae017c34e8
Time: 2017-03-16
Author: mezz@johnmihalic.com
File Name: homeassistant/components/sensor/neurio_energy.py
Class Name:
Method Name: setup_platform


Project Name: home-assistant/home-assistant
Commit Name: 903cda08b153400849409c253cbc8051af53a503
Time: 2018-01-08
Author: cameron.b.llewellyn@gmail.com
File Name: homeassistant/components/light/insteon_local.py
Class Name:
Method Name: setup_platform


Project Name: home-assistant/home-assistant
Commit Name: 903cda08b153400849409c253cbc8051af53a503
Time: 2018-01-08
Author: cameron.b.llewellyn@gmail.com
File Name: homeassistant/components/switch/insteon_local.py
Class Name:
Method Name: setup_platform