New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Domoticz Dummy sensortype usage #3
Comments
Personally, I modified a bit the code in order to send data to a virtual sensor "Electric (Instant + Counter)": it requires 2 values: an instant value (in Watts) and a total value (in WattsHour); I also have a generic (simple) custom virtual sensor for "today production" and another one for "total production". To be able to retrieve the instant power generated, the code needs to call the "getDevRealKpi" API call (hence, you need to have the "inverter" device ID (you may get that with a "getDevList" API call, the inverter is the device with type "38"), and to call "getStationRealKpi" for the total power produced value. You need the code to cope with "too many API calls in a small amount of time", amount of time which is quite ramdom for the getDevRealKpi call (varies from max 1 call every minute to max 1 call every 8 minutes, go figure...). I attach the "HuaweiSolar.env" and "HuaweiSolar_API.sh" I modified. What I use for the "Electric (Instant + Counter)" is "HuaweiSolar_API.sh InverterRealTime". HuaweiSolar_API.sh.txt Here is my crontab:
|
Thx for this, it seems my "devTypeId": 1 for the Inverter and the is "id": , that's the one I need for the .env file? And I can't get to refresh the token anymore |
My inverter has an ID = 1000000035294540. Normally, calling "HuaweiSolar_API.sh Devices" should give you the info, like this:
Regarding the token, this is the code I have (and which works):
|
Running that command gives this error: ./HuaweiSolar_API.sh: line 73: gdate: command not found But I do get a list of devices. |
Oh, yes, gdate is gnu date, required to be able to handle the "+%s%3N" format to get milliseconds. I am on MacOS, and the builtin "date" is not the GNU one. If your system is like a Raspberry, just remove the 'g' of gdate. |
Ok. One last issue: how to get the data to domoticz? In the .env file there is no entry to refer to the DomoticzID sensor. |
Oops, right, I included an old .env file :-( I updated my message above. And please take again the "HuaweiSolar_API.sh" as well, I corrected it as per your comments about gdate. The ID for the Electrical virtual sensor must be filled in here
|
I will change it, I noticed after 25 min you cannot get a new token anymore with the new .sh file. |
If you run the get_token.sh script by hand, what is happening ? |
get_token.sh: 6: get_token.sh: source: not found I run command: sh get_token.sh Hope that is the correct way |
get_token.sh and HuaweiSolar.env must be executable (chmod +x ) and in the same directory. ./get_token.sh should run the script. If it runs, maybe comment out the line "rm $mydir/.$$" and look at the created "results." files and the last.token file |
It generated 3 results files: Seems a 0 length token? { HTTP/1.1 200 OK HTTP/1.1 200 OK |
No "last.token" file in the directory ? |
There is last.token file in the same directory. It’s empty, maybe it also needs to be executable? |
no, last.token does not have to be executable. Just to be sure: you have put the new lines from "HuawaiSolar.env.txt" into "HuaweiSolar.env", correct ? (the files I have put here had the ".txt" extension because it is not allowed to upload ".sh" or ".env" files). The file sizes I have are: Can you try to execute "get_token.sh" in debug mode ? |
I also see in your screen shot that some results are 218 bytes, other 121. If all were the results of the get_token script, the ones with 121 bytes should be the ones notifying an error (without XSRF token), but the ones with 218 bytes should contain the XSRF token. |
Yes, I manually edited the .txt file and renamed it to .env
get_token.sh => 409
I get all the data, can't post it here (You will then have full access to my API account etc). So I put only the last part. myToken seems empty
|
This is the results file. Old token, it will not update { |
That result file is the update of the Domoticz Huawei_XSRF_token_epoch variable, not one from get_token. For instance, this is a result file from a successful get_token execution.
I do not have much more idea to help you :-( |
I can get new token via Postmaster app as suggested by Huawei manual from there support website Running ./HuaweiSolar_API.sh InverterRealTime Y on the PI just gives me output that the token is >25 min old and it won't retrieve a new token. So strange it won't update the token |
Maybe that is because the Huawei_XSRF_token_epoch variable in Domoticz is wrongly updated ? The HuaweiSolar_API.sh relies on the stored value of that variable in Domoticz to decide if the get_token.sh script needs to be called or not (for instance, mine was updated around 11:52 - it is now 11:58 here - and the variable contains 1664185920). Can you check the value of the variable in Domoticz, and use an epoch converter (like: https://www.epochconverter.com ) to check the time it represents ? |
Will do that tonight, no acces to Domoticz at the moment. I just used the original HuaweiSolar_API.sh and the original HuaweiSolar.env, not your edited versions and the token is retrieved with no issue. I am breaking my head here, why that is :-( Hopefully Domoticz variable issue |
It runs fine here, I do not see what can go wrong :-( BTW, I put in my post above a new version of the "HuaweiSolar_API.sh". Regarding token refreshing, as far as I know, the only thing I touched in the CheckToken() mechanism is the line "myEpoch=$EPOCHSECONDS" because EPOCHSECONDS is only available in bash from version 5 (and my OS still runs bash version 3.2.57(1), hence I merely used "myEpoch=$(date +%s)" which should run everywhere. Also, regarding InfluxDB injection, I changed
with
because I use InfluxDB version 2. |
I feel stupid...found a typo in the username in the .env file, after correction it started working fine. Let me try and look tonight in Domoticz at the data and see what more data we can utilize (for instance the battery) I will have a closer look at the _API.sh file if I can edit myself for battery data. But probably need some help with this . |
No problem, I got my share of such typos during my own tries :-) I am still waiting for the installation of the batteries (Luna 2000 10kWh), so your work will be appreciated in a very near future :-) If it may be of use, this is the V6 API reference: Michel |
Yes, typos are so easily overlooked. I already use the new HuaweiSolar_API.sh. A 10kWh battery is big! Why you chose 10 if I may ask? I have 5 kWh, and with this weather it will never be fully charged. I hope I can figure out how to make it work for the battery data. Rik |
In Belgium, since last year, the "prosumers" (the ones producing more than they consume) even have to pay a tax (we have a strange kind of ecologists here... They even make the nuclear power plants to stop and replace them with gaz turbines, because they still have "nuclear no thank you" motto from the last decades. Even the kWh reinjected to the grid are not bought by the power company, it is like we offer them that energy. Anyway. With the solar panels (I have them since this September 2, 2022, with a 3.2 kWc capacity), and I already see they produce more than 2 kWh during 3-4 hours, over the 800 Wh I need, even with a cloudy weather. Hence, seeing that, I really prefer to self-consume a maximum of energy rather than offering it graciously to the energy company, and I immediately ordered the battery. Regarding the capacity, 10 kWh, if filled in, would suffice to cover the night needs, and I guess if the summers are even less sunny than the last one, the 10 kWh will be almost filled each day. I already saw that without the battery, I consume 1/3 less than before from the grid, with the batteries, it may go to 1/2 my normal consumption at least. I expect to have a return of investment in less than 4 years. Michel |
Not for several days, but I have seen that when I was using another way to get the total energy produced value (not using an openAPI account, but relying on the normal customer account). It never happened since I use the (modified) Goumjer script. To explain what was happening with my old way to get the data: around after midnight, the value of the previous day "energy produced" was subtracted from the "total energy produced" value, leading to a negative value when the Domoticz graphing system sees that artefact. As I said, with the modified Goumjer script, this subtraction never occurred again (the values of the total energy produced keep increasing). But to check why (for next night) you may add the line
at the end of the "InverterRealTime ()" function, and look at the values at the time the negative data happens. If the issue is a temporary backwards value in the "total produced energy", there is a way to cope with it by always comparing the currently read total value to the previous one and ignore a backwards value, like with a code like this:
(code to put after the line myTotalWh=$(echo "scale=0; ${myTotalkWh} * 1000 / 1" | bc | sed 's/^./0./') ) I however think this may be a one time issue due to the fact that yesterday was the first day you filled in the data for that sensor. The way the data are processed by Domoticz graphing system is still a black box to me (I use that system since 1 week only now :-) ) |
So you may use in the File Station the functionality to share a file or a folder (Action Menu -> Share) or to request a file (Action menu -> Create file request) (that is how I did it :-) ) |
This part? Can install 2 panels All to the left is another house |
OK, not easy from here to see the dimensions; but even it is only 2 panels, it is already 800 W more stable. So, where do you want to move (some) of the panels then ? |
That's East-West. Or move the current array a bit more South-West add optimizers and add 2 extra panels on the south roof. I doubt so much in this, my installer says this south based is the best....I don't know... |
The only thing sure (but only in my own opinion, I am not expert at all) is that where they are now, the panels are in the shadows in winter. Which is less to happen if they are on a slope roof in height, not on a flat roof boxed between walls. |
Ah well, it's winter now and don't want to get to critical. I have the idea that my converter is not running very efficient at the moment. 3 phase inverter, if I calculate Power = U * I and then take the PowerInverter value from the inverter and divide it PInverter/P * 100% I get around 86% at the moment. So maybe add this domoticz and calculate realtime. The efficiency API call is always 100%, Huawei is looking into it. |
Another info from Huawei active power - AC-side power of the inverter |
Hmmm... Interesting By the way, I wanted to go that way (charging during night at the low rate price), but as I can get the installer password, no way for me to configure that temporarily (seems they refuse to give me the password and they will charge 100 € to do the config change, each time (so also for returning at the Max Auto-consumption settings when the sun will be there fully again). I hate that "job protection" concept. |
You can do it from the app, under Dongle you can set TOU and under battery how far you want to charge. What energy supplier to you have? |
Oh, yes, today, I have access to TOU. 2 days ago, it said something like "this functionality has been disabled by the Installer". As energy supplier, Engie Electrabel. Why ? |
So, you try 😌
To share our surplus energy :-) I have now Eneco, it's possible in Belgium |
Should be OK, isn't it ? In Wallonia, till 2030, the production is subtracted from the consumption (like it was with an analogue power meter with the wheel running backwards). In Brussels and Flanders, if I have the correct information, it is no more possible, thus your sharing system may come handy (otherwise you need to "sell" the extra energy to the grid at a lower price). |
Yes, I have something similar, but only for today, because Fluvius was working on the grid today and I did not want to be shut off, so I charged my battery last night to cover the shut off of the power grid.
That's like in NL it seems, but then a battery is not necessary? |
I prefer to have a battery, because, who knows if they will not change their mind before 2030 ;-) It happened before.
Do you mean the inverter can power your house even if the grid is down ? Because normally, this kind of autonomous working requires a special additional module. I have a question: in TOU mode, if the PV produce more energy than required in the house during the day (so outside the "charging from the grid period", they will recharge the battery (if it is not yet full) ? Or this occur only in "max auto consumption" mode ? |
You can choose in the TOU settings what you want then: charge battery or inject into the grid Huawei did an update, last API value are off and seem to be corrected later, however Domoticz has now big negative and positive values (To compensate). Maybe remove them in Domoticz? |
Yes, in fact, I set that correctly (by accident ;-) ), see my screen shot ! Arf, I feel stupid to have asked.
I had such issues each time they do their maintenance. I had bad results after removing the "wrong" data the first time. Hence now, I do not change anything, the daily strange values are only visible during 1 day. Afterwards, things go back to normal. |
Thinking of adding another 5 kWh battery are you happy with your 2x 5kWh? |
Why? ;-) I sometimes oversee things also
|
I am quite happy with the 10 kWh battery, certainly now that I configured the TOU, I will have most of the day consumption at low rate (my hourly consumption is 1 kWh steady during the entire 24h day). In the spring, I will see if is is better to limit the night charge to 80 or 70 % to make room for the PV production, and then 50 % or disable it in April-May and go back to max self-consumption. It will require some tuning thus (the night charge if good in order to pay the low price instead of the high price, but when the sun will be there, the battery must not be too full already :-) ). |
You have big difference between day and night tariffs? |
You should go for dynamic price contract with Engie and develop your own script when to charge your battery with the P1 data from your meter. Plus when to sell electricity when price is high (feed into the grid). Is that something you could make? I don't know if there is an API to retrieve the hourly electricity prices and adapt your battery system accordingly. bliq.energy has this (it's in dutch only), but we should we not be able to write a smart script for this :-) |
|
No problem to get the periods of the low prices from the P1 Smart Meter; more difficult is to send commands to the Huawei Inverter, the API is only capable of retrieving data, not sending settings as far as I know. |
Ah yes, somehow it seems possible as there is a commercial solution already. But you pay 299 euro for the box and 7euro monthly fee for it. I don't know if Huawei support has a solution for it. |
Do we need to use only the dummy sensor with sensor type custom sensor?
Would be nice to have also diagrams besides the graph, with sensor type electric or usage we can generate diagrams.
The text was updated successfully, but these errors were encountered: