homewizard / python-homewizard-energy

HomeWizard Energy API implementation in Python. Designed for Home Assistant but can be used for any Async application.
https://api-documentation.homewizard.com
Apache License 2.0
14 stars 4 forks source link

fails to run #359

Closed folkertvanheusden closed 6 months ago

folkertvanheusden commented 6 months ago

When I run the example from the README.md, I get:

Device(product_name='P1 meter', product_type='HWE-P1', serial='...', api_version='v1', firmware_version='4.14')
Data(wifi_ssid='...', wifi_strength=44, smr_version=50, meter_model='ISKRA 2M550E-1013', unique_meter_id='...', active_tariff=2, total_energy_import_kwh=..., total_energy_import_t1_kwh=..., total_energy_import_t2_kwh=..., total_energy_import_t3_kwh=None, total_energy_import_t4_kwh=None, total_energy_export_kwh=0, total_energy_export_t1_kwh=0, total_energy_export_t2_kwh=0, total_energy_export_t3_kwh=None, total_energy_export_t4_kwh=None, active_power_w=696, active_power_l1_w=695, active_power_l2_w=None, active_power_l3_w=None, active_voltage_v=None, active_voltage_l1_v=233.8, active_voltage_l2_v=None, active_voltage_l3_v=None, active_current_a=None, active_current_l1_a=2.973, active_current_l2_a=None, active_current_l3_a=None, active_apparent_power_va=None, active_apparent_power_l1_va=None, active_apparent_power_l2_va=None, active_apparent_power_l3_va=None, active_reactive_power_var=None, active_reactive_power_l1_var=None, active_reactive_power_l2_var=None, active_reactive_power_l3_var=None, active_power_factor=None, active_power_factor_l1=None, active_power_factor_l2=None, active_power_factor_l3=None, active_frequency_hz=None, voltage_sag_l1_count=8, voltage_sag_l2_count=None, voltage_sag_l3_count=None, voltage_swell_l1_count=2, voltage_swell_l2_count=None, voltage_swell_l3_count=None, any_power_fail_count=8, long_power_fail_count=3, active_power_average_w=None, monthly_power_peak_w=None, monthly_power_peak_timestamp=None, total_gas_m3=..., gas_timestamp=datetime.datetime(2024, 5, 2, 20, 30, 2), gas_unique_id='...', active_liter_lpm=None, total_liter_m3=None, external_devices={'...': ExternalDevice(unique_id='...', meter_type=<DeviceType.GAS_METER: 3>, value=..., unit='m3', timestamp=datetime.datetime(2024, 5, 2, 20, 30, 2))})
Traceback (most recent call last):
  File "/home/folkert/t/python-homewizard-energy/homewizard_energy/homewizard_energy.py", line 31, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/folkert/t/python-homewizard-energy/homewizard_energy/homewizard_energy.py", line 114, in state_set
    await self.request("api/v1/state", method=METH_PUT, data=state)
  File "/home/folkert/t/python-homewizard-energy/homewizard_energy/homewizard_energy.py", line 248, in request
    raise NotFoundError("Resource not found")
homewizard_energy.errors.NotFoundError: Resource not found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/folkert/t/python-homewizard-energy/./test.py", line 19, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/folkert/t/python-homewizard-energy/./test.py", line 16, in main
    await api.state_set(power_on=True) # Turn on the Energy Socket outlet
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/folkert/t/python-homewizard-energy/homewizard_energy/homewizard_energy.py", line 33, in wrapper
    raise UnsupportedError(f"{func.__name__} is not supported") from ex
homewizard_energy.errors.UnsupportedError: state_set is not supported

What is going wrong here? It worked for a while (in home assistant) and suddenly (since a few weeks) we get this error.

DCSBL commented 6 months ago

Eh, the state command is for an Energy Socket but you use this with a P1 Meter.

Remove the “set_state” command and try again.

Can you explain what this README has to do with Home Assistant?

folkertvanheusden commented 6 months ago

Oh, right, it works fine indeed!