can't import pyplumio when i launch my script
speedypidz opened this issue · 10 comments
Is there an existing issue for this?
- I have searched the existing issues
I'm having the following issue:
Hi,
First thank you so much for your so interresting job, it make me want to learn Python. i'm a noob on python so i hope i will not disturb you to much.
Sorry fo my english i'm french :§)
i'm experiencing the same problem on mac, Wndows and Raspi, i try to launch this script
import asyncio
import pyplumio
async def main():
async with pyplumio.open_tcp_connection("192.168.20.50", 8899) as connection:
ecomax = await connection.get_device("ecomax")
print(await ecomax.get_value("heating_temp"))
asyncio.run(main())
and i have this message
python3 test.py
Traceback (most recent call last):
File "/home/pi/test.py", line 2, in
import pyplumio
File "/home/pi/.local/lib/python3.11/site-packages/pyplumio/init.py", line 4, in
from pyplumio.connection import Connection, SerialConnection, TcpConnection
File "/home/pi/.local/lib/python3.11/site-packages/pyplumio/connection.py", line 15, in
from pyplumio.protocol import Protocol
File "/home/pi/.local/lib/python3.11/site-packages/pyplumio/protocol.py", line 16, in
from pyplumio.frames.requests import StartMasterRequest
File "/home/pi/.local/lib/python3.11/site-packages/pyplumio/frames/requests.py", line 15, in
from pyplumio.frames.responses import DeviceAvailableResponse, ProgramVersionResponse
File "/home/pi/.local/lib/python3.11/site-packages/pyplumio/frames/responses.py", line 13, in
from pyplumio.structures.network_info import NetworkInfoStructure
File "/home/pi/.local/lib/python3.11/site-packages/pyplumio/structures/network_info.py", line 7, in
from pyplumio.helpers.network_info import (
File "/home/pi/.local/lib/python3.11/site-packages/pyplumio/helpers/network_info.py", line 43, in
@DataClass
^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 1220, in dataclass
return wrap(cls)
^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 1210, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 958, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 815, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'pyplumio.helpers.network_info.EthernetParameters'> for field eth is not allowed: use default_factory
For information i use the home assistant plungin and it works
My environment is:
- OS: Windows 10, Raspi buster
- Python: Python 3.11
I have following devices connected:
- ecoMAX 3xx series
- ecoMAX 8xx series
- ecoMAX 9xx series
- Expansion module B
- Expansion module C
- ecoSTER 200/ecoSTER Touch
- ecoLAMBDA
- ecoNET 300
I'm connecting to my devices using:
Ethernet/WiFi to RS-485 converter
I'm seeing following log messages:
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Hi,
Thank you for you feedback and kind words!
This one is my fault actually. Python's dataclasses don't allow mutable types to be used as a default values for the fields, due to possible unexpected behavior.
Previously mutability was determined by disallowing certain types from being used, but since Python 3.11, we have this note in dataclass documentation:
Changed in version 3.11: Instead of looking for and disallowing objects of type list, dict, or set, unhashable objects are now not allowed as default values. Unhashability is used to approximate mutability.
Both EthernetParameters() and WirelessParameters() here are unhashable, so in Python 3.11 this leads to an error.
Home Assistant uses Python 3.10 as default version hence no error there.
It's now fixed via using default_factory.
Great, thank you so much for your help ! i just tested and it work like charm :-)
Sorry, last question, could you tell me how to use device.data to list the information available on my ecomax ? thank you
You can wait for loaded
value.
It's available once all device data has been loaded.
I modified your code from above:
import asyncio
import pyplumio
async def main():
"""Collect device data and dump it to the console."""
async with pyplumio.open_tcp_connection("192.168.20.50", 8899) as connection:
ecomax = await connection.get_device("ecomax")
# Wait until all data is loaded.
await ecomax.get_value("loaded")
# Print collected data.
print(ecomax.data)
asyncio.run(main())
If you just want to look at what data your EM provides, you can also use the script, that I made to collect diagnostic data.
https://gist.github.com/denpamusic/5df805524738ea1bb9c00d25ed351c46
You'll need to change HOST and PORT values at the top of the file to suit your use case.
HOST = "192.168.20.50"
PORT = 8899
After running this script, it'll collect all device data and save it to the ecomax_data.json
file.
Thank you Denis, i have an ecomax log boiler, and i have some more interesting information, i will be happy to share it with you to help you to make your HA more rich. i will be so grateful to follow how to upgrade your Dev and perhaps make the job with some help if you have some time. also i can already give you the french translation if needed. Nicolas
{
"config": {
"abort": {
"already_configured": "Appareil déja connecté"
},
"error": {
"cannot_connect": "Connexion échouée",
"timeout_connect": "Delai de connexion dépassé",
"unknown": "Erreur inattendue"
},
"step": {
"user": {
"data": {
"connection_type": "Type de connexion",
"device": "Chemin de l'appareil",
"host": "Hôte",
"port": "Port"
}
}
}
}
}
{
"state": {
"plum_ecomax__state": {
"off": "Off",
"fanning": "Ventilation",
"kindling": "Allumage",
"heating": "Chauffe",
"paused": "Pause",
"idle": "Inactif",
"standby": "En attente",
"burning_off": "Brulage",
"alert": "Alerte",
"unknown": "Unknown"
}
}
}
Thank you for the translation!
I've added it to the integration (denpamusic/homeassistant-plum-ecomax@1a329ff) and it'll be part of upcoming v0.3.1 release. Yes, we're jumping one minor up in integration version number due to the recent improvements to the stream handler in PyPlumIO.
Any help with this project is very much appreciated! For the next step, I'm looking into supporting Plum thermostats (ecoSTER's) in HASS. PyPlumIO is already supports them at low level, but it's one thing to have a raw values and another to decipher their meanings. Since I don't have thermostat myself, I'll be relying on community to provide information. I'll raise the issue in the integration repository, after I'll release v0.3.1.
Thanks again for the help!👍
Don't hesitate to contact me if you have any questions and problems.
With Pleasure :-), i'm so grateful for your work. with your integration i don't need to go every time downstair to see if i have to light the fire, or add wood :-). I'm 42 and i wanted to learn Python for long time and so it's really a good start. I'm always worried to don't disturb people, so don't hesitate to tell me if you thing i'm boring.
On my side i think that there some element interesting to had when you have have a log boiler
"state": 2,
"fan": false,
"feeder": false,
"heating_pump": true,
"water_heater_pump": false,
"ciculation_pump": false,
"lighter": false,
"alarm": false,
"outer_boiler": false,
"fan2_exhaust": true,
"feeder2": false,
"outer_feeder": false,
"solar_pump": false,
"fireplace_pump": false,
"gcz_contact": false,
"blow_fan1": false,
"blow_fan2": false,
"heating_pump_flag": true,
"water_heater_pump_flag": true,
"circulation_pump_flag": true,
"solar_pump_flag": false,
"heating_temp": 82.31214904785156,
"outside_temp": 0.9454335570335388,
"exhaust_temp": 93.01554107666016,
"optical_temp": 0.0,
----------"upper_buffer_temp": 87.86424255371094,
----------"lower_buffer_temp": 87.79934692382812,
"heating_target": 90,
"heating_status": 0,
"water_heater_target": 50,
-------------"water_heater_status": 128,
"pending_alerts": 0,
"fuel_level": 0,
------------"transmission": 8,
"fan_power": 0.0,
"load": 5,
"power": 0.0,
"fuel_burned": 0.0,
"fuel_consumption": 0.0,
"thermostat": 1,
And the speed of the Fan but i can't see it in the Json export.
So i have a question could you help me to know witch files i have to edit to had this informations in the code. It will help me to make the modifications. Many thanks
I'm sorry, I don't quite understand. Could you please clarify which code you want to modify?
To get a value, you simply need to await Device.get_value()
with the value name as an argument. For example to get fan speed, you do something like in example below. I also suggest, that you use timeouts, because otherwise your call can wait forever in case of a problem.
import asyncio
import pyplumio
async def main():
"""Get fan power value and dump it to the console."""
async with pyplumio.open_tcp_connection("192.168.20.50", 8899) as connection:
ecomax = await connection.get_device("ecomax")
# This will get you fan speed.
try:
fan_power = await ecomax.get_value("fan_power", timeout=5)
print(f"Fan power: {fan_power}")
except asyncio.TimeoutError:
print("Failed to read fan power")
asyncio.run(main())
Sorry for my english Denis, i saw that you made some modification to you code to had some more informations. On my log boiler i have an ecomax 860 D3 and i wanted to see in home assistant this items
----------"upper_buffer_temp": 87.86424255371094,
----------"lower_buffer_temp": 87.79934692382812,
-------------"water_heater_status": 128,
and "fan2_exhaust": true, status and power but i can't retrieve it :-)
It's okay, you probably wouldn't have understood my french either😂 I like french and wanted to learn it someday, but sadly there is never enough time to learn everything you'd like to learn :(
Anyways I understand now, that you want these added to the hass integration. In that case could you, please, send me json file, that you've got from my script to denpa@denpa.pro. I'll review it and add these values to integration ASAP.