gmeks / myUplinkSmartConnect

This program connect to the myuplink.com and adjust the schedule of Høiax CONNECTED hot water heaters, and adjust the schedule so that it uses electricity when the price is low.
8 stars 1 forks source link

How does the software interact with "modi" #1

Closed TheAlpiner closed 2 years ago

TheAlpiner commented 2 years ago

Hi, nice work. Just got a 200L Høiax Connected installed and found your software. I tested it out in a container and it seems to have connected ok. I just wanted to know how it interacts with the different "MODI"s. I had a set point for 60 and it changed to 70. But I have not changed and done anything to the MODI setup. Does your software use MODIS in an intelligent way? Did not find anything in the documentation for this. Below is my log file

[16:19:44 INF] Starting up service [16:19:44 INF] Reading settings from configuration file [16:19:46 ERR] Failed to get updated price information, from EU API. Checking nordpool [16:19:48 INF] Found device with ID: ########### [16:19:49 WRN] Water heater target temperature is incorrect ({setting.value}) for {mode.name} , changing to 70 [16:19:49 WRN] Water heater desired power level is incorrect for {mode.name} , changing from {setting.HelperDesiredHeatingPower} to M4 (70C, 700W) [16:19:49 WRN] Water heater target temperature is incorrect ({setting.value}) for {mode.name} , changing to 70 [16:19:49 WRN] Water heater desired power level is incorrect for {mode.name} , changing from {setting.HelperDesiredHeatingPower} to M5 (70C, 1300W) [16:19:51 INF] Changed schedule for ######### [16:19:51 ERR] Failed to connect to MTQQ server

But so far this looks very promising. :-)

gmeks commented 2 years ago

Hey,

The way it uses modes it uses 3 seperate modes

M6) target temp 70C, max watt 2000.

M5) Target temp 50c, max watt 700

M4) Target temp 50, but no heating allowed.

The basic idea is to use the low prices, to heat up the water to 70c ( That means there is no random legionenal program needed). And if needed M5 kicks inn, and keeps the water hoot.

Il expand more on it tomorrow, see if i cannot expand the docs.

TheAlpiner commented 2 years ago

Thank you for your reply, Your use of the modes sounds smart. Avoiding accidental running of legionella programs can be a wise saving measure, i thought it was smart to lower the set point to 60 degrees but then the legionelle program kicks in from time to time. I am just starting to get familiar with the heater, modes and the general functionality and i noticed in the iOS app that last night the heater was in "external control". I think it switched to that when running your program but i am not sure. The settings from the program did not seem to kick in before i changed to schedule/timeplan. After that everything seems to work.

Bereder

Do you know if that is what it should be doing? It makes sense to manually switch the modes because then i can activate holiday mode without doing anything to your program. One final question. When do the software change the schedule? In Norway i think the next days prices are released around 13:00 does the software fetch the prices at regular intervals or once a day?

I will test the MQTT integration next. I have Home Assistant running so interesting to see if i can integrate them. Not sure how to use the integration yet but for statistics and visuals it could be interesting. Thank you for making this software . So far everything works and does what it is suppose to do... i think :-)

gmeks commented 2 years ago

Heater should be in schedule mode i belive. Thats when it checks the remote API to see what to do, but please note that it does not check instant.

The current method it works in, is to use lower electricity price to build up as much energi as posible in the tank, and store it there during high cost periods. For me it seems using 70c as target temprature is the best middle ground, that way it lasts for many hours but does not "leak out" right away. Like using 80c target does.

Setting up homeassistant is a great idea, then you get to see what its doing. And perhaps combining our experiences will see the different knobs we will need to to have adjustable ( Like change target temprature of modes).

It might also be posible to use a different kind of target mode, we instead say that we want X amount of hot water at XX and YY. Basicity just making sure that it uses the best spot in the night for getting enough water for the morning showers. Currently the application does not have any "usage" information so i cannot know how much hot water is needed at different times.

The prices are released at 13:00, the application spreads out when it does the reschedule at a unique pr user time after this but before 22:00.

Yea my plan for vacation was to change the heater to vacation mode. And then 1-2 before we come back switch it to schedule. If we ever get to the point with full homeassisatnt integration it would be posible to many of these things from homeassistant.

TheAlpiner commented 2 years ago

I tested the MQTT connection and i can see it connect in the Mosquito logs

1656686551: New connection from 10.199.0.88:47088 on port 1883. 1656686551: New client connected from 10.199.0.88:47088 as 96913ebd5ab5441fb83f21c085ac58ce (p2, c1, k15, u'mqtt').

But i can not see any action. I checked with mqtt-analyzer and no messages seems to come in. The funny thing after i updated the appsettings.json with the correct mqtt settings it does not seem to update the schedule for tomorrow.

[14:42:30 INF] Target Schedule change time is 13:17 [14:42:30 INF] Starting up service [14:42:30 INF] Reading settings from configuration file [14:42:31 INF] Found device with ID: HOIAX_#### d59

But if you say it can happen any time before 22 i will wait :-)

Any idea what i could do to get more loginfo about the MQTT part ?

:-)

gmeks commented 2 years ago

Im a bit confused, your using appconfig when running via docker? In docker you should be using envromental variables ( I would recommend at least).,

Based on your setup, the target time is 13:17.

You should be seeing log lines like [16:00:09 INF] Found device with ID: HOIAX_X [16:00:11 INF] Changed schedule for HOIAX_X

There is a LogLevel setting ( or just write debug in console when its running) .

And regarding reschedule on restart, turns out there was a bug. Thats fixed, il build a new version tomorrow... For your setup it will run the schedule tomorow. It will not force on reboot

Can you verify the CheckRemoteStatsIntervalInMinutes 1 setting? MQTT messages should be sendt 1 time pr minute, and its multiple messages pr minute

TheAlpiner commented 2 years ago

It changed the schedule a little later so that part works greast just had to wait :-)

[16:00:39 ERR] Failed to get updated price information, from EU API. Checking nordpool [16:00:46 INF] Found device with ID: HOIAX### [16:00:48 INF] Changed schedule for HOIAX####

Did not get any further with MQTT integration though

Im a bit confused, your using appconfig when running via docker? In docker you should be using envromental variables ( I would recommend at least).,

Yes probably should, it was a quick fix just to test. :-)

There is a LogLevel setting ( or just write debug in console when its running) .

And regarding reschedule on restart, turns out there was a bug. Thats fixed, il build a new version tomorrow... For your setup it will run the schedule tomorow. It will not force on reboot

OK, great

Can you verify the CheckRemoteStatsIntervalInMinutes 1 setting? MQTT messages should be sendt 1 time pr minute, and its multiple messages pr minute

That setting is there. I can do som more research on the MQTT problem. I have not dived very deep into it. The strange thing is it seems to connect but no messages is coming. The schedule seems to work great but it fire an error eaxch time on EU API it seems. Or maybe it says nothing when it goes ok :-)

gmeks commented 2 years ago

It should do a fallback to another API if EU is down. But its easy to check in the myapi website to verify that it updated the schedule.

in regards to MQTT im running the one that comes as a homeassistant addon. Running via docker compose like this.

version: "2"

services:
  server:
    image: erlingsaeterdal/myuplinksmartconnect:latest
    restart: always
    pull_policy: always
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    environment:
      - TZ=Europe/Oslo     
      - UserName=eks@something
      - Password=anothersupersercretpassword
      - IsInsideDocker=1
      - CheckRemoteStatsIntervalInMinutes=1      
      - WaterHeaterMaxPowerInHours=5
      - WaterHeaterMediumPowerInHours=12
      - PowerZone=NO2
      - MQTTServer=192.168.50.10
      - MQTTServerPort=1883
      - MQTTUserName=homeassistant
      - MQTTPassword=supersecretpassword
gmeks commented 2 years ago

I pushed tag erlingsaeterdal/myuplinksmartconnect:1.0.0.5 added more logging for you, and fixed the schedule not starting on app restart.

gmeks commented 2 years ago

Btw appconfig seems to not support strings, so setting LogLevel to 1 to set debug.

TheAlpiner commented 2 years ago

I pushed tag erlingsaeterdal/myuplinksmartconnect:1.0.0.5 added more logging for you, and fixed the schedule not starting on app restart.

Great thanks, i will test the new version and also see if the extended logging will help. 🙂👍

gmeks commented 2 years ago

Its in erlingsaeterdal/myuplinksmartconnect:latest now, i have experienced a flaw that can make it stop doing updates. Seems to be related to homeassistant reboots. But not sure yet

gmeks commented 2 years ago

I think i found the bug, that could make stop doing updates. It was as expected very stupid, patch is in latest

TheAlpiner commented 2 years ago

Hi, I have updated to the latest version and can now verify with MQTT explorer that it is sending messages to the broker.

[11:29:57 INF] Target Schedule change time is 17:17 [11:29:57 INF] Starting up service [11:29:57 INF] Reading settings from environmental variables [11:29:57 INF] Reporting to MQTT is: True [11:30:58 INF] Found device with ID: HOIAX_###

But for some reason it is not creating them in HomeAssistant. I think that is due to my lack of knowledge regarding HA. I have verified with the MQTT Explorer that the topic header is correct but it still not creating the sensors. But i will dig into this. Thank you for your continuing work on this. The updates to myuplink worked flawlessly in the last version. I will check after 17:17 today :-)

gmeks commented 2 years ago

It will not create then, you have to add it to configuration.yml like the example:

 sensor:
   - platform: mqtt
     state_topic: "heater/18760NE2240322014631/TargetTemprature"
     unique_id: "WaterHeaterTargetTemprature"
     name: "Target temprature"
     unit_of_measurement: "°C"

   - platform: mqtt
     state_topic: "heater/18760NE2240322014631/CurrentTemprature"
     unique_id: "WaterHeaterCurrentTemprature"
     name: "Current temprature"
     unit_of_measurement: "°C"

   - platform: mqtt
     state_topic: "heater/18760NE2240322014631/EstimatedPower"
     unique_id: "WaterHeaterEstimatedPower"    
     name: "Current Watt"
     device_class: power    
     state_class: measurement    
     unit_of_measurement : W   

  - platform: mqtt
    state_topic: "heater/18760NE2240322014631/EnergyTotal"
    unique_id: "WaterHeaterEnergyTotal"
    name: "Energy Total"    
    device_class: power
    state_class: total_increasing
    unit_of_measurement : kWh    

  - platform: mqtt
    state_topic: "heater/18760NE2240322014631/EnergiStored"
    unique_id: "WaterHeaterEnergiStored"
    name: "Energi in tank"
    device_class: power
    unit_of_measurement : kWh        

  - platform: mqtt
    state_topic: "heater/18760NE2240322014631/FillLevel"
    name: "Tank fill level"
    unique_id: "WaterHeaterFillLevel"    
    unit_of_measurement: '%'

  - platform: mqtt
    state_topic: "heater/18760NE2240322014631/LastScheduleChangeInHours"
    name: "Last schedule change"
    unique_id: "LastScheduleChange" 
TheAlpiner commented 2 years ago

The schedule updated ok

[11:29:57 INF] Target Schedule change time is 17:17 [11:29:57 INF] Starting up service [11:29:57 INF] Reading settings from environmental variables [11:29:57 INF] Reporting to MQTT is: True [11:30:58 INF] Found device with ID: HOIAX??? [15:00:51 INF] Found device with ID: HOIAX??? [15:00:53 INF] Changed schedule for HOIAX_??? for today and tomorrow

I have created this in HomeAssistant:

And then this:

Not sure if pictures from gmail will look ok on github but i am on holiday so sending this from my phone :-)

I had to change because i got a deprecated message when using your syntax. This got rid of all messages … but it did not work so it did not help much. I will look more into it tonight. One funny thing and misinformation from last message. The old version did send mqtt messages :

The new version of your program does not send anything to my broker. But again might be my holiday brain that has missed something. I recreated the container with the :latest instead of :1.0.0 in the dockerfile … the previous version sent messages the new one dont. MQTT Explorer does not pick up anything. But i will check if i have done anything wierd :-)

I sense i am on my competence edge here regarding mqtt and homeassistant. So i will dig and hopefully learn more. But a little strange that it does not send anything after just recreating the container. ——-

tor. 14. jul. 2022 kl. 15:04 skrev Erling K. Sæterdal < @.***>:

It will not create then, you have to add it to configuration.yml like the example:

sensor:

  • platform: mqtt

    state_topic: "heater/18760NE2240322014631/TargetTemprature"

    unique_id: "WaterHeaterTargetTemprature"

    name: "Target temprature"

    unit_of_measurement: "°C"

  • platform: mqtt

    state_topic: "heater/18760NE2240322014631/CurrentTemprature"

    unique_id: "WaterHeaterCurrentTemprature"

    name: "Current temprature"

    unit_of_measurement: "°C"

  • platform: mqtt

    state_topic: "heater/18760NE2240322014631/EstimatedPower"

    unique_id: "WaterHeaterEstimatedPower"

    name: "Current Watt"

    device_class: power

    state_class: measurement

    unit_of_measurement : W

    • platform: mqtt

    state_topic: "heater/18760NE2240322014631/EnergyTotal"

    unique_id: "WaterHeaterEnergyTotal"

    name: "Energy Total"

    device_class: power

    state_class: total_increasing

    unit_of_measurement : kWh

    • platform: mqtt

    state_topic: "heater/18760NE2240322014631/EnergiStored"

    unique_id: "WaterHeaterEnergiStored"

    name: "Energi in tank"

    device_class: power

    unit_of_measurement : kWh

    • platform: mqtt

    state_topic: "heater/18760NE2240322014631/FillLevel"

    name: "Tank fill level"

    unique_id: "WaterHeaterFillLevel"

    unit_of_measurement: '%'

    • platform: mqtt

    state_topic: "heater/18760NE2240322014631/LastScheduleChangeInHours"

    name: "Last schedule change"

    unique_id: "LastScheduleChange"

— Reply to this email directly, view it on GitHub https://github.com/gmeks/myUplinkSmartConnect/issues/1#issuecomment-1184423154, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVEHJ2YUVJFDOILABQLAKN3VUAF4XANCNFSM52J7VQLA . You are receiving this because you authored the thread.Message ID: @.***>

gmeks commented 2 years ago

docker pull on latest to make sure it updated?

I cannot see the picture, if you enable debug logging it will print everything a message is sendt.

TheAlpiner commented 2 years ago

Hi,

Sorry to bother you with all this but this is a neat little app and it could be really fun and useful to get into HA. My docker config says this now:

Version: "2" services: server: image: erlingsaeterdal/myuplinksmartconnect:latest restart: always pull_policy: always environment:

It seems to pick the latest version correctly. The strange thing is when it said 1.0.0 in stead of latest and pulled an older version it pushed MQTT messages trough. I got this from MQTTAnalyzer then:

MA

but after i changed to the latest it dos not send any messages trough anymore. HA debug is picking up sensor config for MQTT:

2022-07-16 12:59:48 DEBUG (SyncWorker_15) [homeassistant.components.mqtt.client] Subscribing to heater/BerederVaskerom/TargetTemprature, mid: 1 2022-07-16 12:59:49 DEBUG (SyncWorker_10) [homeassistant.components.mqtt.client] Subscribing to heater/BerederVaskerom/CurrentTemprature, mid: 2 2022-07-16 12:59:49 DEBUG (SyncWorker_14) [homeassistant.components.mqtt.client] Subscribing to heater/BerederVaskerom/EstimatedPower, mid: 3 2022-07-16 12:59:49 DEBUG (SyncWorker_10) [homeassistant.components.mqtt.client] Subscribing to heater/BerederVaskerom/EnergyTotal, mid: 4 2022-07-16 12:59:49 DEBUG (SyncWorker_0) [homeassistant.components.mqtt.client] Subscribing to heater/BerederVaskerom/EnergiStored, mid: 5 2022-07-16 12:59:49 DEBUG (SyncWorker_7) [homeassistant.components.mqtt.client] Subscribing to heater/BerederVaskerom/FillLevel, mid: 6

Could it be something in your code? When i change docker config to 1.0.0 (image: erlingsaeterdal/myuplinksmartconnect:1.0.0) it starts to send messages trough again. But then the update to myuplink is buggy. It could still be me i know i am stretching my knowledge a bit here... but learning. It just seems strange that older version send messages trough and newer dont. :-)

gmeks commented 2 years ago

It can offcourse be my code, i make mistakes like a true natural :)

But can you verify that th esettings are correct? In the first version i spelled MQTT wrong, so i had to rename all the settings.....

So going from first version release to latest will not work because the settings names are different..... Settings went from: MTQQServer to MQTTServer . I can see that this was not well documented in changelog... And i dont have logging to show the currect settings.

TheAlpiner commented 2 years ago

Hi,

Interesting but my docker config file is as follows:

version: "2" services: server: image: erlingsaeterdal/myuplinksmartconnect:latest restart: always pull_policy: always environment:

gmeks commented 2 years ago

The fix for wrong spelling was v1.0.0-beta3.

Can you add - LogLevel=1 so we can see if its trying to send

TheAlpiner commented 2 years ago

I rest my case. For some magical reason the topics started to show up. Thank you for your patience, the loglevel in your app and debug in homeassistant made me realise that the problem was entierly my big thumbs and typing errors. So now i have the sensors in.

701CCBBD-5C19-4CDA-A662-7CEFFE28610B

🙂👍

gmeks commented 2 years ago

Thats great, if you spot a way to improve the documentation let me know.

Seems this high electricity prices is gonna contiune, so i suspect this program will contiune to be usefull. Let me know if you discover other ways to improve :)

TheAlpiner commented 2 years ago

I will,

I have a couple of suggestions or ideas. But so far it has worked great... well the app acctually stopped last afternoon for some reason. This is the logg :-)

server_1 | [16:18:05 DBG] Sending update BerederVaskerom - EnergyTotal - 100.2 server_1 | [16:18:05 DBG] Sending update BerederVaskerom - EnergiStored - 10.3 server_1 | [16:18:05 DBG] Sending update BerederVaskerom - FillLevel - 100 server_1 | [16:19:05 DBG] Last schedule was 23.001721019305556 hours ago and above minimum hour for schedule start True server_1 | [16:19:05 DBG] Failed to get updated price information, from EU API. Checking nordpool server1 | [16:19:07 INF] Found device with ID: HOIAX### server1 | [16:19:09 INF] Changed schedule for HOIAX### for today and tomorrow server_1 | [16:19:09 DBG] Sending update BerederVaskerom - LastScheduleChangeInHours - 0 server_1 | [16:19:09 DBG] Sending update BerederVaskerom - LastScheduleChangeInHours - 23 server_1 | [16:19:09 DBG] Updated status for 1 devices server_1 | [16:19:09 DBG] Next status update in 1.0694894116666667 should update now True server_1 | [16:19:09 DBG] Found 0 devices, will attemt to check for status updates server_1 | [16:20:09 DBG] Next status update in 1.0000032216666668 should update now True server_1 | [16:20:09 DBG] Found 0 devices, will attemt to check for status updates

i restarted it and after that it found the device again and has worked. But a couple of suggestions :

The second. I did not get your HA exampe to work. And according to the docs it seems like your way is an oudatet way to do it (https://www.home-assistant.io/integrations/sensor.mqtt/)

. My config is this now like this;

mqtt: sensor:

But everything seems to work now exept for the stop yesterday... :-)

gmeks commented 2 years ago

Yea there was a edge case if local cache got corrupted it could potensialy stop doing status updates next schedule update, i added a check for it in latest.

And i improved the readme

TheAlpiner commented 2 years ago

OK, great. I will reload with new image and test. The new readme is very good. One thing if you write down possible improvements for later releases ;-) What could be really nice if we could get some kind of info upfront over MQTT if something goes wrong. I now have to check console/log from docker. But if the app for some reason can not update schedule or fail to login or something. Could it be a sensor that dsiplays current status or something in HA ... I have not though this all trough but since i check my HA lovelace space quite regularly, if a message there could indicate that there was something wrong... Just an idea. The last schedule change is great, just maybe some improvment on the status of the app. But it is already a great app :-)

gmeks commented 2 years ago

Yea the idea was LastScheduleChange to be used by HA for automations, but it might be a good idea with some sort of descriptive text also.

I agree i would love to all controll done from homeassistant, with 2 way communication allow for something as simple as setting it in vacation mode now :)

TheAlpiner commented 2 years ago

Closing this issue