flopp999 / Tibber-Domoticz

Script to communicate with Tibber. Help me with a buy-me-a-coffee
https://www.buymeacoffee.com/flopp999
GNU General Public License v3.0
8 stars 4 forks source link

Subscription #14

Closed DeVille70 closed 2 years ago

DeVille70 commented 3 years ago

Any chance you could expand to also support subscription, please? subscription{ liveMeasurement(homeId:"c70dcbe5-4485-4821-933d-a8a86452737b"){ timestamp power
maxPower } }

DeVille70 commented 3 years ago

Ok, I guess you want to change it then, but it seems to be running fine now.

flopp999 commented 3 years ago

@DeVille70 updated again, please try when you got time thanks

DeVille70 commented 3 years ago

Yes, will do. Very busy at the moment, but hopefully tonight.

DeVille70 commented 3 years ago

Sorry for the long delay, I have been very busy. Installed the new script, and it has been running for a few minutes now. Looks good. :)

Proposal for future versions: The Tibber subscription also offers the variables minPower, averagePower, and maxPower. Not sure I see any use of those for myself at the moment, but perhaps others will.

flopp999 commented 3 years ago

I also saw that there are a lot more.

Please have a look here and tell me if you need more data. It is fun to add features :)

Do you have solar cell at home? I want to add data for production as well.

https://developer.tibber.com/docs/reference

DeVille70 commented 3 years ago

Wow, that was a long list, I was not aware of that. Perhaps the ones I mentioned as well as PriceLevel.

Not sure what the negative effects on Domoticz and the RPi of loading too much data every 10-12 seconds would be, though.

No, I have no solar cells.

flopp999 commented 3 years ago

I will add your proposals. I only collect data once per hour, let’s start with this and see if that is enough. Otherwise I can collect more often for maxPower and other that may change often. Price and PriceLevel will only change every hour Thanks for your input

DeVille70 commented 3 years ago

👍

flopp999 commented 3 years ago

@DeVille70 I have now updated branch 0.90 with 5 new devices. The 3 that you "asked" for and also accumulated cost and accumulated consumption. If you got time to test I'll be happy :)

DeVille70 commented 3 years ago

It looks good.

The 5 new devices did not update until after close to an hour, but I guess that is as intended.

Great work!

flopp999 commented 3 years ago

Thank you. Correct, the new devices will update next minute 0, or if you restart Hardware twice. Will fix this in the future.

eirikman commented 3 years ago

Great work!

sorry, change HomeID in plugin.py. I will add this ass a text field in the stable version

You can get the HomeID with:


{
  viewer {
    homes {
      id
    }
  }
}

So the user does not need to add it manually.

Btw, it is also important to close the websocket connection when Domoticz exits, since you can have max 3 open connections to Tibber.

Regards Daniel (author of the Tibber integration in Home Assistant)

More than one house I have a house and a cabin, both with power from Tibber. Would be nice to be able to input home ID or address in order to select the location of interest. As it is now, it apears that the first house in houses is selected

Sugestion: Allow for home ID as optional input

If no home ID is given:
    Find home ID of first house in houses
else:
    Find the house in houses with the given home ID
    Use the house found
flopp999 commented 3 years ago

Great work!

sorry, change HomeID in plugin.py. I will add this ass a text field in the stable version

You can get the HomeID with:


{
  viewer {
    homes {
      id
    }
  }
}

So the user does not need to add it manually. Btw, it is also important to close the websocket connection when Domoticz exits, since you can have max 3 open connections to Tibber. Regards Daniel (author of the Tibber integration in Home Assistant)

More than one house I have a house and a cabin, both with power from Tibber. Would be nice to be able to input home ID or address in order to select the location of interest. As it is now, it apears that the first house in houses is selected

Sugestion: Allow for home ID as optional input

If no home ID is given:
    Find home ID of first house in houses
else:
    Find the house in houses with the given home ID
    Use the house found

I think I can do a solution. Please create a new issue with the request. This issue is solved and long :)

DeVille70 commented 2 years ago

Sorry to bug you again. This plugin has worked excellently since March, but after a crash I partially had to rebuild my system. Installing this plugin does not go so well. No devices are created, and even if I select Tibber API 1.11 it comes up as Tibber API 0.89. Any advise to share, please?

DeVille70 commented 2 years ago

From Domoticz log: 2022-01-05 14:34:58.510 Error: Tibber: (Tibber) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Tibber-Domoticz/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'. 2022-01-05 14:34:58.510 Error: Tibber: (Tibber) Module Import failed, exception: 'ModuleNotFoundError' 2022-01-05 14:34:58.510 Error: Tibber: (Tibber) Module Import failed: ' Name: python_graphql_client' 2022-01-05 14:34:58.510 Error: Tibber: (Tibber) Error Line details not available.

flopp999 commented 2 years ago

I have had other people also having problem since yesterday. I don't know why, maybe an update for a package? Anyway please update again to 1.12, I just did a change in 1.11 Please tell me how it goes :)

DeVille70 commented 2 years ago

Thanks for quick response. So I replace the plugin.py file, and restart Domoticz. Then plugin version 1.12 is available to install, but after installation it shows up as 0.89 in Hardware list. And no devices are installed.

From Domoticz log: 2022-01-05 15:03:34.102 Error: Tibber 1.12: (Tibber) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Tibber-Domoticz/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'. 2022-01-05 15:03:34.102 Error: Tibber 1.12: (Tibber 1.12) Module Import failed, exception: 'SyntaxError' 2022-01-05 15:03:34.102 Error: Tibber 1.12: (Tibber 1.12) Import detail: File: /home/pi/domoticz/plugins/Tibber-Domoticz/plugin.py, Line: 49, offset: -1 2022-01-05 15:03:34.102 Error: Tibber 1.12: (Tibber 1.12) Error Line '"""

flopp999 commented 2 years ago

Please restart DZ. Did you copy the text and paste or did you download the file and replaced the file?

DeVille70 commented 2 years ago

Restarted Domoticz, but to no change.

I copied and pasted text into the file, yes. I have limited linux skills, and the Windows tool i use for file browsing had access problems.

flopp999 commented 2 years ago

OK, because I think some of the text was copied/pasted in wrong way. Please try to copy the text as raw from Github or replace the file(recommended)

DeVille70 commented 2 years ago

Ok, I copied via raw into a new file, and now 8 devices showed up. But they are all about power, and one about signal strength, and the ones I had before with min, max, and current price are no longer there. Has the plugin changed function?

DeVille70 commented 2 years ago

Ok, prices perhaps comes only every midnight. But power updates is much rarer now, every 30 s or so. And still reports API version 0.89 in Hardware.

flopp999 commented 2 years ago

Ok, I copied via raw into a new file, and now 8 devices showed up. But they are all about power, and one about signal strength, and the ones I had before with min, max, and current price are no longer there. Has the plugin changed function?

Depends how old the other version was. I think I changed ID for the devices around version 0.75. Otherwise it shall give you lots of devices, if you have a Real-time sensor

flopp999 commented 2 years ago

Ok, prices perhaps comes only every midnight. But power updates is much rarer now, every 30 s or so. And still reports API version 0.89 in Hardware.

Did the prices came up? Yes, I changed so it will update Real-time data every 10 seconds and it will only update ~10 devices then after 10 seconds another 10 devices and so on. Restart DZ to see the correct version under Hardware. In DZ log when you start the plugin it should give 1.12

DeVille70 commented 2 years ago

I have 17 Tibber devices, but none of them are prices. The device Tibber-power only updates every 30 seconds. In hardware still says 0.89. Under Home ID it only says Yes, no actual ID

From Domoticz log: 2022-01-07 07:20:37.795 Error: Tibber: (Tibber) 'onMessage' failed 'TypeError':''NoneType' object is not subscriptable'. 2022-01-07 07:20:37.795 Error: Tibber: (Tibber) ----> Line 500 in '/home/pi/domoticz/plugins/Tibber-Domoticz/plugin.py', function onMessage 2022-01-07 07:20:37.795 Error: Tibber: (Tibber) ----> Line 265 in '/home/pi/domoticz/plugins/Tibber-Domoticz/plugin.py', function onMessage

flopp999 commented 2 years ago

Strange that it still says 0.89.

Can you try to replace plugin.py again.

Check that you copy the file from Main branch on GitHub

DeVille70 commented 2 years ago

The old plugin folder, with 0.89 is still there, and I am not able to delete it. So it seems that the plugin.py from the old folder is read, even though I select 1.12. In fact, it seems both plugin.py files are read, because in the hardware page pretty much all information is displayed twice. image

flopp999 commented 2 years ago

Why can't you not delete it? try "sudo rm -r [folder name]"

if there is two folder with same plugin-name(inside plugin.py) it can be strange behavior

DeVille70 commented 2 years ago

I had tried sudo rm before but -r seems to to do the trick. Now 1.12 shows up in hardware. But power updates only every 30 secs and no prices. I'll leave it until tomorrow and see then.

Thanks so far.

DeVille70 commented 2 years ago

Restarting Domoticz: 2022-01-11 23:26:19.529 Error: Tibber: (Tibber) 'onMessage' failed 'TypeError':''NoneType' object is not subscriptable'. 2022-01-11 23:26:19.529 Error: Tibber: (Tibber) ----> Line 500 in '/home/pi/domoticz/plugins/Tibber-Domoticz/plugin.py', function onMessage 2022-01-11 23:26:19.529 Error: Tibber: (Tibber) ----> Line 265 in '/home/pi/domoticz/plugins/Tibber-Domoticz/plugin.py', function onMessage

DeVille70 commented 2 years ago

Same situation. Still no prices, power updates every 30 secs, and most of the other devices stopped updating at different times throughout the night.

flopp999 commented 2 years ago

Fix is in version 1.13 that I just uploaded.

DeVille70 commented 2 years ago

Thanks. There are now more devices, 25 in total, but still no prices. And power updates now around every 50 seconds.

flopp999 commented 2 years ago

I may have forgotten but do you buy electricity from Tibber? If not you will get any prices. Great that you get more devices now. Yes, every 50 second it updates power. I had to change this because of timeout when asking for data. Version 1.14 the text in DZ log will be correct. Now it still says "... every 10 seconds..."

DeVille70 commented 2 years ago

Yes,, I buy electricity from Tibber.

Every 50 sec is not very often. Is it because downloading all the other data, like current and voltage for each phase, and other things?

flopp999 commented 2 years ago

I have two other persons that also use 1.13 and they get prices. Can you attach Tibber log file. What parameter/s do you want every 10 seconds? power, minPower, maxPower, powerProduction, powerReactive, powerProductionReactive, minPowerProduction, maxPowerProduction, lastMeterProduction, powerFactor, voltagePhase1, voltagePhase2, voltagePhase3, currentL1, currentL2, currentL3, signalStrength, lastMeterConsumption, accumulatedConsumption, accumulatedProduction, accumulatedConsumptionLastHour, accumulatedProductionLastHour, accumulatedCost, accumulatedReward, averagePower

flopp999 commented 2 years ago

I have two other persons that also use 1.13 and they get prices. Can you attach Tibber log file. What parameter/s do you want every 10 seconds? power, minPower, maxPower, powerProduction, powerReactive, powerProductionReactive, minPowerProduction, maxPowerProduction, lastMeterProduction, powerFactor, voltagePhase1, voltagePhase2, voltagePhase3, currentL1, currentL2, currentL3, signalStrength, lastMeterConsumption, accumulatedConsumption, accumulatedProduction, accumulatedConsumptionLastHour, accumulatedProductionLastHour, accumulatedCost, accumulatedReward, averagePower