w1ll1am23 / pyeconet Goto Github PK
View Code? Open in Web Editor NEWPython 3 interface to the EcoNet API
License: MIT License
Python 3 interface to the EcoNet API
License: MIT License
I've been setting up the Econet integration for the first time in HA and immediately observed an error in the logs about an unknown mode:
Logger: pyeconet.equipment.water_heater
Source: /usr/lib/python3.9/site-packages/pyeconet/equipment/water_heater.py:60
First occurred: 4:15:09 PM (727 occurrences)
Last logged: 9:14:37 PM
Unknown mode: [Electric/Gas ]
Context: My Water Heater was warranty-swapped with a new unit ~1 week ago. The old (Installed August '21) had an "electric" mode available, not "Electric/Gas." I hadn't noticed before this error, but the app does indeed have an "Electric/Gas" mode listed (with no icon) where the "Electric" mode used to live.
Has anyone else seen a similar change/error? I don't know which generation my prior model was, but this new one describes itself as heatpumpWaterHeaterGen5
, which is newer than what I saw in the API response examples.
Does anyone else have a gen5 unit yet? Is anyone with gen4 or older seeing an electric/gas mode appear?
get_locations response:
{
"results": {
"locations": [
{
"@AWAY": false,
"@AWAYCONFIG": false,
"@LOCATION_INFO": "XXX, XXX",
"@LOCATION_NAME": "Home",
"@LOCATION_STATUS": "I'm Home",
"@VACATION": false,
"@VACATIONCONFIG": false,
"@WEATHER": "51°",
"@WEATHER_F": 51,
"@WEATHER_I": "clearn.png",
"equiptments": [
{
"@ACTIVE": true,
"@ALERTCOUNT": 0,
"@AWAY": false,
"@AWAYCONFIG": false,
"@AWAY_MSG": "",
"@BCONFIG": [
{
"align": "center",
"name": "@SCHEDULESTATUS",
"type": "TEXT_LABEL_VIEW",
"value": ""
},
{
"name": "@SCHEDULERESUME",
"title": "Resume",
"type": "BUTTON_VIEW",
"value": ""
},
{
"align": "center",
"type": "TEXT_LABEL_VIEW",
"value": "Hot Water Availability"
},
{
"align": "center",
"name": "@HOTWATER",
"title": "Hot Water Availability",
"type": "SINGLE_IMAGE_VIEW",
"value": "ic_tank_hundread_percent_v2.png"
}
],
"@COMBUSTION": {
"constraints": {
"formatDecimal": 1,
"green": 55,
"lowerLimit": 0,
"orange": 25,
"red": 20,
"units": "HRS",
"upperLimit": 10000000
},
"status": "Compressor life is normal",
"value": 100
},
"@CONFIG": [
{
"align": "center",
"name": "@MODECONFIG",
"title": "This Equipment should be set to ENERGY SAVING Mode for maximum efficiency",
"type": "IMAGE_TEXT_BUTTON_VIEW",
"value": {
"constraints": {
"bgcolor": "#008000",
"enumText": [
"Off ",
"Energy Saver ",
"Heat Pump ",
"High Demand ",
"Electric/Gas ",
"Vacation "
],
"enumTextIcon": [],
"fontcolor": "#FFFFFF",
"icon": "ic_energy_saver",
"lowerLimit": 0,
"upperLimit": 5
},
"status": "Enable",
"value": 1
}
}
],
"@CONNECTED": true,
"@DRACTIVE": {
"constraints": {
"dialog": [
{
"message": "This should not impact the water temperature in your home. Do you want to opt out for this event ?",
"title": "Tank temperature has been changed in response to a Utility Load Control event",
"value": 1
}
]
},
"value": ""
},
"@DRESOVER": {
"constraints": {
"enumText": ["false", "true "],
"enumTextIcon": [],
"lowerLimit": 0,
"upperLimit": 1
},
"status": "false",
"value": 0
},
"@ENABLED": {
"constraints": {
"enumText": ["Disabled", "Enabled "],
"enumTextIcon": ["ic_device_off.png", "ic_enabled.png"],
"lowerLimit": 0,
"upperLimit": 1
},
"status": "Enabled ",
"value": 1
},
"@HOTWATER": "ic_tank_hundread_percent_v2.png",
"@JA13STATUS": "",
"@LEAKINSTALLED": {
"constraints": {
"align": "center",
"bgcolor": "#bec2bf",
"enumText": ["No ", "Yes"],
"enumTextIcon": [],
"fontcolor": "#000000",
"lowerLimit": 0,
"upperLimit": 1
},
"status": "",
"title": "Leak sensor not installed",
"value": 0
},
"@MODE": {
"constraints": {
"enumText": [
"Off ",
"Energy Saver ",
"Heat Pump ",
"High Demand ",
"Electric/Gas ",
"Vacation "
],
"enumTextIcon": [
"ic_device_off.png",
"ic_energy_saver.png",
"ic_heat_pump.png",
"ic_high_demand.png",
"http://heaticon.png",
"ic_vacation.png"
],
"lowerLimit": 0,
"upperLimit": 5
},
"status": "High Demand ",
"value": 3
},
"@MODECONFIG": {
"constraints": {
"bgcolor": "#008000",
"enumText": [
"Off ",
"Energy Saver ",
"Heat Pump ",
"High Demand ",
"Electric/Gas ",
"Vacation "
],
"enumTextIcon": [],
"fontcolor": "#FFFFFF",
"icon": "ic_energy_saver",
"lowerLimit": 0,
"upperLimit": 5
},
"status": "Enable",
"value": 1
},
"@MODEIMAGE": "",
"@NAME": {
"constraints": {
"stringLength": 64
},
"value": "Heat Pump Water Heater"
},
"@OVERRIDE": {
"constraints": {
"bgcolor": "#FFFF00",
"fontcolor": "#000000",
"icon": "ic_high_level_alert.png"
},
"status": "",
"value": ""
},
"@OVERRIDESTATUS": "",
"@RESUME": false,
"@RUNNING": "Compressor Running",
"@SCHEDULE": false,
"@SCHEDULERESUME": "",
"@SCHEDULESTATUS": "",
"@SETPOINT": {
"constraints": {
"error": [],
"formatDecimal": 0,
"isConversion": true,
"lowerLimit": 110,
"units": "deg F",
"upperLimit": 140,
"warning": [
{
"message": "CAUTION HOT WATER. Contact may cause serious burns to skin",
"value": 121
}
]
},
"value": 120
},
"@STATUS": "Enabled ",
"@TANK": {
"constraints": {
"green": 40,
"orange": 30,
"red": 30
},
"status": "Element operating normally",
"value": 100
},
"@TCONFIG": [
{
"align": "center",
"name": "@MODEIMAGE",
"type": "SINGLE_IMAGE_VIEW",
"value": ""
},
{
"align": "center",
"name": "@RUNNING",
"type": "TEXT_LABEL_VIEW",
"value": "Compressor Running"
},
{
"align": "center",
"name": "@OVERRIDESTATUS",
"type": "TEXT_LABEL_VIEW",
"value": ""
}
],
"@TYPE": "heatpumpWaterHeaterGen5",
"@VACATION": false,
"@VALVE": {
"constraints": {
"dialog": [
{
"message": "Closing the shut off valve will disable the water heater",
"title": "Closing Valve",
"value": 0
}
],
"error": []
},
"value": ""
},
"@VALVESTATUS": {
"constraints": {
"align": "center",
"bgcolor": "#bec2bf",
"fontcolor": "#000000"
},
"status": "",
"title": "Shut-OFF Valve not installed",
"value": 1
},
"actions": [
"waterheaterScheduleView",
"networkSettings",
"waterheaterUsageReportView",
"waterheaterHealthView"
],
"device_name": "",
"device_type": "WH",
"mac_address": "",
"serial_number": ""
}
],
"location_id": ""
}
]
},
"success": true,
"logs": "",
"stack": ""
}
On this line, we're making an assumption of 100% full. I haven't actually seen the API responses in depth, but it seems like None should be the default. If something like 5% comes back, we're mapping to 100%. Though I'm also not sure why 100, 40, 10 are the only defaults when the app shows 100, ⅔, ⅓, or empty (I'm guessing Rheem is dumb)
My gladiator support vacation mode. Here is the response data. Hopefully @appleguru can also add their data as well so we can get proper support.
{
"results": {
"locations": [
{
"@AWAY": false,
"@AWAYCONFIG": true,
"@LOCATION_INFO": "Somewhere, WY",
"@LOCATION_NAME": "Home",
"@LOCATION_STATUS": "I'm Home",
"@VACATION": false,
"@VACATIONCONFIG": false,
"@WEATHER": "60°",
"@WEATHER_F": 60,
"@WEATHER_I": "clearn.png",
"equiptments": [
{
"@ACTIVE": true,
"@ALERTCOUNT": 0,
"@AWAY": false,
"@AWAYCONFIG": true,
"@AWAY_MSG": "",
"@BCONFIG": [
{
"align": "center",
"name": "@SCHEDULESTATUS",
"type": "TEXT_LABEL_VIEW",
"value": ""
},
{
"name": "@SCHEDULERESUME",
"title": "Resume",
"type": "BUTTON_VIEW",
"value": ""
},
{
"align": "center",
"type": "TEXT_LABEL_VIEW",
"value": "Hot Water Availability"
},
{
"align": "center",
"name": "@HOTWATER",
"title": "Hot Water Availability",
"type": "SINGLE_IMAGE_VIEW",
"value": "ic_tank_hundread_percent_v2.png"
}
],
"@CONNECTED": true,
"@DRACTIVE": {
"constraints": {
"dialog": [
{
"message": "This should not impact the water temperature in your home. Do you want to opt out for this event ?",
"title": "Tank temperature has been changed in response to a Utility Load Control event",
"value": 1
}
]
},
"value": ""
},
"@ENABLED": {
"constraints": {
"enumText": [
"Disabled",
"Enabled"
],
"enumTextIcon": [
"ic_device_off.png",
"ic_enabled.png"
],
"lowerLimit": 0,
"upperLimit": 1
},
"status": "Enabled",
"value": 1
},
"@HOTWATER": "ic_tank_hundread_percent_v2.png",
"@LEAKINSTALLED": {
"constraints": {
"align": "center",
"bgcolor": "#11ab00",
"enumText": [
"No",
"Yes"
],
"enumTextIcon": [],
"fontcolor": "#000000",
"lowerLimit": 0,
"upperLimit": 1
},
"status": "",
"title": "Leak sensor connected",
"value": 1
},
"@NAME": {
"constraints": {
"stringLength": 64
},
"value": "Gladiator Water Heater"
},
"@OVERRIDE": {
"constraints": {
"bgcolor": "#FFFF00",
"fontcolor": "#000000",
"icon": "ic_high_level_alert.png"
},
"status": "",
"value": ""
},
"@OVERRIDESTATUS": "",
"@RESUME": false,
"@RUNNING": "",
"@SCHEDULE": false,
"@SCHEDULERESUME": "",
"@SCHEDULESTATUS": "",
"@SETPOINT": {
"constraints": {
"error": [],
"isConversion": true,
"lowerLimit": 110,
"unit": 1,
"upperLimit": 140,
"warning": [
{
"message": "CAUTION HOT WATER. Contact may cause serious burns to skin",
"value": 121
}
]
},
"value": 120
},
"@STATUS": "Enabled",
"@TANK": {
"constraints": {
"green": 55,
"orange": 25,
"red": 20
},
"status": "Element operating normally",
"value": 100
},
"@TCONFIG": [
{
"align": "center",
"name": "@OVERRIDESTATUS",
"type": "TEXT_LABEL_VIEW",
"value": ""
},
{
"align": "center",
"name": "@RUNNING",
"type": "TEXT_LABEL_VIEW",
"value": ""
}
],
"@TYPE": "hotspringWaterHeater",
"@VACATION": false,
"@VALVE": {
"constraints": {
"dialog": [
{
"message": "Closing the shut off valve will disable the water heater",
"title": "Closing Valve",
"value": 0
}
],
"enumText": [
"Open",
"Close"
],
"enumTextIcon": [],
"error": [],
"lowerLimit": 0,
"upperLimit": 1
},
"status": "Open",
"value": 0
},
"@VALVESTATUS": {
"constraints": {
"align": "center",
"bgcolor": "#11ab00",
"fontcolor": "#000000"
},
"status": "",
"title": "Shut-OFF Valve - Open",
"value": 1
},
"actions": [
"waterheaterScheduleView",
"networkSettings",
"waterheaterUsageReportView",
"waterheaterHealthView"
],
"device_name": "123456789",
"device_type": "WH",
"serial_number": "MY_SERIAL"
}
],
"location_id": "976ett7c-1686-4559-b9f0-5715gg1d2a26"
}
]
},
"success": true,
"logs": ""
}
I see the following 2 errors on every restart. All works as expected and I have been seeing this in the logs since I implemented the integration.
2022-10-09 15:06:06.561 ERROR (MainThread) [pyeconet.equipment] Unknown equipment type state: None
2022-10-09 15:06:06.574 ERROR (MainThread) [pyeconet.equipment] Unknown equipment type state: None
The errors have carried through all the versions of HA throughout the last year. (I'm always running the latest versions)
I have 2 econet thermostats, let me know what else I can provide or debug for you.
there is a small issue with fan modes:
pyeconet.equipment.thermostat ERROR thermostat:by_string: Unknown fan mode: [Medium Lo]
pyeconet.equipment.thermostat ERROR thermostat:by_string: Unknown fan mode: [Medium Hi]
In the class ThermostatFanMode(Enum)
MEDLO should be MEDIUMLO
MEDHI should be MEDIUMHI
"@fanspeed": {
"constraints": {
"enumText": [
"Auto",
"Low",
"Medium Lo",
"Medium",
"Medium Hi",
"High"
],
thanks for providing this api
Describe the bug
Running the test program in the SRC directory; I'm getting a "username / email" incorrect error. I've confirmed via my phone app that my email / password is correct.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expected the username / password to work
Screenshots
DEBUG:pyeconet.api:{'options': {'message': 'Incorrect Email id or Password', 'success': False}, 'user_id': '<USER_ID>', 'user_token': '<AUTH_TOKEN>'}
Traceback (most recent call last):
File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode
exec(code, self.locals)
File "/config/Nextcloud/Programming/Python/econet test.py", line 40, in <module>
loop.run_until_complete(main())
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/config/Nextcloud/Programming/Python/econet test.py", line 17, in main
api = await EcoNetApiInterface.login(email, password=password)
File "/config/.local/lib/python3.10/site-packages/pyeconet/api.py", line 79, in login
await this_class._authenticate({"email": email, "password": password})
File "/config/.local/lib/python3.10/site-packages/pyeconet/api.py", line 244, in _authenticate
raise InvalidCredentialsError(_json.get("options")["message"])
pyeconet.errors.InvalidCredentialsError: Incorrect Email id or Password
Additional context
I'm relatively new to python.
I'm running this on a Linux machine.
Describe the bug
Users experiencing MQTT disconnects.
To Reproduce
Steps to reproduce the behavior:
Doesn't impact all users but the users it impacts it appears to be impacting consistently.
Expected behavior
MQTT shouldn't disconnect unexpectedly with any sort of consistent frequency.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Originally reported here.
When trying to use the test.py program I am seeing an incorrect import reference:
dputzolu@Lenovo:~/temp/pyeconet/src$ python3 test.py
Traceback (most recent call last):
File "test.py", line 6, in <module>
from pyeconet import EcoNetApiInterface
File "/home/dputzolu/temp/pyeconet/src/pyeconet/__init__.py", line 2, in <module>
from .api import EcoNetApiInterface # noqa
File "/home/dputzolu/temp/pyeconet/src/pyeconet/api.py", line 9, in <module>
from pyeconet.equipments import Equipment, EquipmentType
ModuleNotFoundError: No module named 'pyeconet.equipments'
dputzolu@Lenovo:~/temp/pyeconet/src$
Great library. Thank you so much for making this!
Is there a library function to figure out the current temperature as read by a thermostat? I've found the running status, but it doesn't tell me how far from set_point we are. Am I missing something?
thanks in advance!
I use Home Assistant which, in turn, uses pyeconet for its Econet integration. I noticed that every time I tried to change my hot water heater's mode (e.g. from "eco" to "high_demand") there would sometimes be a significant delay of minutes until the change would actually happen. This is counter to the official Android app which makes the change immediately.
I scrubbed through the code and noticed that there appears to be a 300 second minimum amount of time required to elapse before any communication goes back to Rheem which likely explains this behavior I'm seeing.
Can you explain why this significant delay was chosen? It also results in long waits between temperature updates (5 minutes I guess). I'm interested to know whether it could possible be made to be customizable to be a shorter span of time or if there were other reasons behind the decision. Thanks.
As of July 23, 3:45 am PDT, PyEcoNet suddenly stopped being able to authenticate for me. Each auth attempt results in:
ERROR:pyeconet.api:Authentication request failed, please check credintials. 400
I am still able to access the EcoNet app, although I understand it uses a different API.
Is anyone else having success authenticating? Or is this the moment of "this library could stop working at any time, without warning"? Or is it a matter of updating (or finding anew) the magic value for BASIC_HEADERS?
How's the new_api branch coming along? :)
Hi,
I noticed that the HomeAssistant Econet integration makes use of pyeconet under the covers. I also noticed that the integration doesn't appear to give me any way of seeing the current water temperature in my hot water tank. Using the physical menu/screen on my hot water heater I can see it has sensors that show multiple temperatures like the upper tank temperature, lower tank temperature, etc.
Is it possible to somehow expose these in the HomeAssistant integration? Or is this a shortcoming of the Econet API where this data is not sent back?
Thanks.
Newer Rheem tankless heaters have a recirculation pump that's controllable from the app.
The main command to run the pump is:
"@RPUMPINSTANCE" which turns on the pump, and looked like this:
{'constraints': {'enumText': ['Off', 'On '],
'enumTextIcon': [],
'lowerLimit': 0,
'upperLimit': 1},
'status': 'Off',
'value': 0}
There is also "@RCOPERATIONS" which returns a nice string like Recirc pump not circulating
Lastly, there is "@RPUMPMODE," which controls how often the pump runs. I think you can ignore this one.
{'constraints': {'enumText': ['None ',
'Timer-Perf. ',
'Timer-E-Save',
'On-Demand ',
'Schedule '],
'enumTextIcon': [],
'lowerLimit': 0,
'upperLimit': 4},
'status': 'On-Demand ',
'value': 3}
I verified that it works via the equipment._api.publish
API in your library.
I would take a stab at a PR, but my python is rusty. Also, it's very unclear to me how/if the API deals with features that are device-dependent.
It would be great to add this to HomeAsstant. Recirculation pumps waste a lot of energy when run on timers. Being able to control them via automation to circulate before use would save energy, and still have relatively fast hot water.
I've been using this library for a few weeks to log data from some EcoNet water heaters. It was working great at first, but recently stopped providing updated data. All of the values in the json returned by get_locations have been the same for over a week.
Has the "unofficial API" stopped working? Strange that I still get a response though...
First of all, thank you for this package. I love it!
On api.py:166, the HEADERS['Authorization'] template is populated with the token returned during authentication. But it seems that this affects the HEADERS global, modifying the 'Authorization' value from 'Bearer %s' to 'Bearer [token]'. Consider the following repro:
print(pyeconet.api.HEADERS)
PyEcoNet(ECONET_USERNAME, ECONET_PASSWORD)
print(pyeconet.api.HEADERS)
PyEcoNet(ECONET_USERNAME, ECONET_PASSWORD)
The first print shows: {'Authorization': 'Bearer %s', 'Content-Type': 'application/json'}
The second print shows: {'Authorization': 'Bearer abcdefg', 'Content-Type': 'application/json'}
And the second PyEcoNet invocation fails with:
Traceback (most recent call last):
File "[redacted]/hpwh/main.py", line 21, in hpwh
econet = PyEcoNet(ECONET_USERNAME, ECONET_PASSWORD)
File "[redacted]/pyeconet/api.py", line 179, in __init__
self.api_interface = EcoNetApiInterface(username, password)
File "[redacted]/pyeconet/api.py", line 42, in __init__
self.authenticated = self._authenticate()
File "[redacted]/pyeconet/api.py", line 166, in _authenticate
_auth = _auth % self.token
TypeError: not all arguments converted during string formatting
The hacky workaround is to re-set HEADERS['Authorization'] before instantiating PyEcoNet.
(In case it matters, this was repro'd in Python 3.7.5.)
Hello,
I'm using water heater with schedule, created by Econet native android app.
At the same time I would like to have possibility to control water heater via HomeAssistant.
Problem is: when I set operation mode to OFF, water heater is set to disabled, and it's own schedule is no longer working.
Using Econet android app I can control operation mode (Off, Eco, Heat Pump, etc) and Enable/Disable unit separately.
May be it is good idea to add Enabled and Disabled to the WaterHeaterOperationMode and enable/disable unit only if it was explicitly requested?
If it is acceptable, I can create PR.
Thanks.
api call to /getLocation returns {'results': {}, 'success': False, 'logs': 'The error has occurred in getLocation'}
its been working perfectly for a few months for me, until yesterday. the awful app continues to work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.