async def test_smoke(inverters_fixture): conn, inverter_class, values = inverters_fixture inv = inverter_class(*conn) rt_api = solax.RealTimeAPI(inv) parsed = await rt_api.get_data() msg = 'data size should match expected values' assert len(values) == len(parsed.data), msg for sensor, value in values.items(): assert parsed.data[sensor] == value
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Platform setup.""" import solax api = solax.RealTimeAPI(config[CONF_IP_ADDRESS]) endpoint = RealTimeDataEndpoint(hass, api) resp = await api.get_data() serial = resp.serial_number hass.async_add_job(endpoint.async_refresh) async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL) devices = [] for sensor in solax.INVERTER_SENSORS: idx, unit = solax.INVERTER_SENSORS[sensor] if unit == "C": unit = TEMP_CELSIUS uid = f"{serial}-{idx}" devices.append(Inverter(uid, serial, sensor, unit)) endpoint.sensors = devices async_add_entities(devices)
async def LoadSolaxData(): # r = await solax.real_time_api(os.environ['SOLAX_IP'],80,'admin') r = solax.RealTimeAPI( inverter.X1MiniV34(os.environ['SOLAX_IP'], 80, 'admin')) return await r.get_data()