def test_total_energy(_, __): """Test extracting total energy from plant.""" sensor = growatt_sensor.GrowattPlantTotal( None, growatt.GrowattApi(), "foo", "bar", ) sensor.update() assert sensor.state == 114.9
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Growatt Plant sensor.""" import growatt username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) growatt_client = growatt.GrowattApi() is_login_success = login(growatt_client, username, password) if is_login_success: sensor_today = GrowattPlantToday(hass, growatt_client, username, password) sensor_total = GrowattPlantTotal(hass, growatt_client, username, password) sensor_current = GrowattPlantCurrent(hass, growatt_client, username, password) add_entities([sensor_today, sensor_total, sensor_current]) return True return False
def test_current_energy(_, __): """Test extracting current energy from plant.""" sensor = growatt_sensor.GrowattPlantCurrent(None, growatt.GrowattApi(), "foo", "bar") sensor.update() assert sensor.state == 142.0
def test_login(_): """Test logging in.""" client = growatt.GrowattApi() login_success = growatt_sensor.login(client, "foo", "bar") assert login_success