-
Notifications
You must be signed in to change notification settings - Fork 17
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
state_class: total_increasing #16
Comments
Hi @Snux - I've just checked through all of the sensors and they are already correct (I was pretty meticulous when I set this up). I'm not sure what issue you're having but it's not related to the configurations of the sensors. What are the specific sensors you're having issues with? I use the all-time totals rather than the daily totals and that works fine as well. |
That's from the old integration, the new one is this one: https://github.com/muppet3000/homeassistant-grott/blob/main/custom_components/grott/sensors/sensors_mqtt.py#L754-L763 It would be called "Import from Grid Energy - Today" |
You can always redownload the integration, the latest version is on the 'main' branch and you can install that. But I'm certain I haven't changed those formats since the initial release. |
Did you add template sensors to replicate the old names at some point? |
No, the only template sensors I have in this area are where I wanted to add 2 together. "Import from Grid Energy - Today" doesn't show at all. I know I've got the right integration as I can see your code in my custom components folder. So how are the sensors above getting updated? I need a lie down :) |
Are you running grott using the egguy add-on? Perhaps the two of them are conflicting with each other in some way? |
Bingo. Yes, I'm using the addon from egguy (was easier to setup). I thought though it was just going to do grott and push stuff at MQTT, but it's actually building all the sensors too. So actually I'm not running your integration at all. You can see all the sensors in the add on here.... Now I'm trying to work out what to do next.... |
How comfortable are you with tweaking some of the code in the |
Happy to give it a shot (let me just grab a backup first!). Ideally I'd just like to use his addon for the grott -> mqtt part as that was remarkably simple to setup. |
So I think this line: https://github.com/muppet3000/homeassistant-grott/blob/main/custom_components/grott/sensor.py#L96 is the killer line in my integration that isn't picking up anything published because the egguy addon doesn't use the default configuration for the MQTT topics. Instead, it looks like it's using this: https://github.com/egguy/grott/blob/feature/ha-extension/examples/Home%20Assistent/grott_ha.py#L49 So, my suggestion, is, look in the custom compoents directory and edit my sensor.py file, the path should be: Change I'm not 100% certain whether this will work, but I think it might. I'm trying to understand a little bit about how that add-on works, however I'm at work and it's a bit difficult to do this as well :P |
It's OK, I'm at work too :) We can do this piecemeal as you get time, no hurry. You're in the right area. I made the change and switched on your debug logging and get this now...
|
Sounds like we're both having a super productive day at work :) That debug printout is much more helpful than you'd realise, the topic is completely different for the HA add-on in that case. For now, revert it back to how it was (so your logs aren't filled with errors from my integration) and let me think it over. With a bit of thought I think we can make it so that we can handle both scenarios so that people that want to use the egguy add-on can without too much difficulty (as you say, it makes the setup nice and easy). I'll produce a feature branch or something (or maybe just a file you can copy in to place) to do some testing for me with it so we can make sure it works in both scenarios. It's a shame I've got no way of running a version of HA that supports the 'add-on' method, otherwise I'd have tested it myself. I need to spend a bit of time getting my head around how the egguy addon actually works, it feels like it's doing about 20 different things:
|
Sounds like a plan, I reverted the change. I never realised his addon did so much. I installed MQTT, then his add on, then your integration pretty much at the same time so when I got a bunch of new sensors I just assumed they were yours :) |
Are you using the Home Assistant MQTT add-on i.e. the one that runs MQTT as part of home assistant? |
Hi @Snux I was planning on looking at this last night, but the heat here in the UK completely wiped me out! My brain just wasn't up to it. Can I ask what instructions you followed to set up the egguy add-on? I've found these ones: https://github.com/egguy/grott/tree/feature/ha-extension/examples/Home%20Assistent based on the link you sent yesterday, but it doesn't explain or show how to run grott. I don't see anywhere in the instructions where it tells you to copy in grott or anything like that, it tells you to modify a grott.ini file though. I'm a little bit confused (maybe it's my brain still catching up from yesterday :P). Alternatively, have I got my wires crossed and you're actually using this one: https://github.com/egguy/grott-home-assistant-add-on ???? |
No worries, I’m in the UK too (sunny Kent) and my home office faces south, so I know the problem 😊
It is indeed this one…
https://github.com/egguy/grott-home-assistant-add-on
From: Chris Straffon ***@***.***>
Sent: Tuesday, June 13, 2023 9:29 AM
To: muppet3000/homeassistant-grott ***@***.***>
Cc: marks sunnucks.com ***@***.***>; Mention ***@***.***>
Subject: Re: [muppet3000/homeassistant-grott] state_class: total_increasing (Issue #16)
Hi @Snux<https://github.com/Snux>
I was planning on looking at this last night, but the heat here in the UK completely wiped me out! My brain just wasn't up to it.
Can I ask what instructions you followed to set up the egguy add-on?
I've found these ones: https://github.com/egguy/grott/tree/feature/ha-extension/examples/Home%20Assistent based on the link you sent yesterday, but it doesn't explain or show how to run grott.
Are you running grott manually??
I don't see anywhere in the instructions where it tells you to copy in grott or anything like that, it tells you to modify a grott.ini file though. I'm a little bit confused (maybe it's my brain still catching up from yesterday :P).
Alternatively, have I got my wires crossed and you're actually using this one: https://github.com/egguy/grott-home-assistant-add-on ????
If you're using that one it makes a whole lot more sense and I reckon we could probably tweak that setup slightly and both of them will work.
—
Reply to this email directly, view it on GitHub<#16 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAEYFKUW62233THYHYSOR3TXLAQE5ANCNFSM6AAAAAAZDCNCE4>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Cool. I normally love the warm weather, but for some reason it wiped me out the last couple of days. Now I know what version of the add-on you're using I'll do a bit more research and try to understand better what it's doing and how it works. I reckon there's a few things we can do to make it work, possibly even without affecting the egguy add-on. |
I've been looking at this in the background today. I've got to a better point of understanding, however this would be sooooo much easier if I had a version of HomeAssistant the supported installing add-ons. I could properly test it then.
Slightly longer version:
In my opinion, now that my Integration exists all that the add-on needs to do is to run the stock grott image and use it to push things straight to mqtt. The problem I have is whether or not the MQTT broker running in HA can be referred to as 'localhost' or not. The reason all the data is in a different format is because the home assistant add-on/plugin for Grott changes the format of the data so that it's different to what it's native MQTT implementation does - which is really weird IMO. Anyway, I'm looking at whether there's a nice way for me to spin up the add-on version of home-assistant in a VM so that I can test my theory and then suggest a new course of action. |
More notes for myself - worked out how to spin up a HomeAssistant OS VM - https://www.home-assistant.io/installation/linux Will attempt to spin one up tonight and have a play with it. Unlikely to get to the point of Grott running, but if I can get the OS up and running that'll be a good result. Will also try to work through some of the other issues in the backlog for my integration to make space for working on this. |
So, I think it might be simpler than this. I looked at the config for the addon and ended up poking around the grott code a bit (yuck - I hate python, I'm too old school). We might just need to raise an issue for a bug on the addon. In the config is this little item.... Following that through, it gets sent into grott as the nomqtt parameter. If this is set to True, grott should skip sending the normal MQTT messages. If false, it should send as normal (which I think your integration would then pick up). I switched on the verbose log from the addon and set the above parm to keep the original grott messages. The below is what popped up in the log
So you can see it's trying to send using the topic you're expecting, but failing with that error 99. Then the addon kicks in and sorts out all it's messages. So I think before you spend all that time getting a new HA setup, why don't I raise an issue against the addon asking for this option to be fixed? |
So that's what I wanted to change in the add-on i.e. the configuration information for where mqtt is. If we could leave this ticket open to allow me to investigate that would be great, rather than closing it just because we've got a work-around. Could you let me know where you found the ini file and what you set the host of the mqtt host to? I was wondering if you could get away with using localhost. Really glad it's working now, even if it's a bit hacky. Let me know any feedback on the integration itself when you get the chance. |
This screenshot shows where the grott.ini is (when installing the addon it creates the file but leaves it empty) I tried with localhost but got the 'address not available' error. I tried to disable the add-on (it's a section called [Extension] in the grott.ini) but the script running it over-rides it. Changing this line in the add-on package to "False" would stop grott from calling it, but would let it still call the normal MQTT publish. https://github.com/egguy/grott-home-assistant-add-on/blob/main/grott-current/script.sh#L68 |
@Snux - Can you confirm how you're running home assistant OS? Just curious how you're poking around on the file system that's all. (I can probably work it out with SSH and some plugin or something, but I'm looking for the shortcut). |
I've got HA OS running and the grott add-on installed. I think I understand how it all pieces together and I'm tempted to fork the egguy add-on and try and get it to simply start grott and push the relevant info to MQTT. I don't think it'll be that hard, I just don't have the mental capacity for it right now! In my opinion it'll be a whole lot cleaner if people can just run Grott and MQTT as add-ons and then use the stand-alone integration to present the data, division of responsibilities etc. etc. |
Now I've slept on it, I think the add-on to just run grott is actually really simple. I'm going to have a crack at it tonight. |
I'm running HAOS on a regular RPi4. There are file editor addons (a simple one, plus full VSCode) which let you open and edit files directly inside HA. Seemingly only within the config folder of HA, but that's all I need it for. Works fine.
Sounds good - no hurry from my side at all, I need to work through my setup switching the sensors over now. Maybe we should rename the issue though as it doesn't actually reflect the cause. |
Thanks, for the info. |
I did see that, but I have such a mess of sensors at the moment (and not just in the growatt area) that I thinking starting afresh is probably a good idea! |
I've started work on a paired down version of the egguy addon, however I'm away for the weekend and I've just realised the HA-OS setup I made the other day at home isn't accessible from where I am, so I'll have to wait to test it. There's no way that I'll get it correct first time so I'll wait until I'm back tomorrow before sharing it (after I've given it a quick test). My intention is to make it just run grott & push the data to mqtt then the integration from this repo will do all the sensor creation etc. |
Just for completeness from the other issue I opened: I managed to go through anything I had on my configuration.yaml and then the mqtt devices with growatt or coming from egguy's plugin, deleted them all, restarted HA and managed to get it all working (battery/charge/discharge on the energy dashboard working fine).
No biggie, though. |
Hi Guys, If you guys are able to stumble on with the hacked config for now, I've realised I've had some long standing issues that I promised I'd fix for people. Then it's this one - I want to have a proper chat with egguy to make sure I'm not treading on his toes. |
Hi,
One of the things to note, the add-on is running in its own networking space and the MQTT server in another. If you put localhost, its refers to the grott add-on address. The mosquito's add-on server address is : PS: Just added a way to disable the HA extension and enable the MQTT output in the edge HA add-on. I've done some tests with the HACS integration, and it works well, but I would love some more feedback. |
@egguy @muppet3000 with the latest edge HA add-on with disable/enable set for the extension/MQTT it's working really well. I'm only missing one sensor, I think it sits in the HA add-on still, but is now disabled. Can you possibly bring back the "Grott last data push" sensor, even if the HA extension is disabled. It's a really quick way to determine if we're updating or not and if there is some issue at the Growatt side. |
Sorry I've been out of touch for a couple of weeks guys I've been really busy with non computery stuff while the weather has been so nice here in the UK. So can I make sure I understand this correctly as there are a few things going on here:
As a side note with regards to seeing if there are issues on the growatt side of things - I'm going to have a look at the grott code at some point and try and implement some logic that allows people to optionally choose to use the 'stubbed' version of grottproxy when growatt isn't responding so that MQTT values will still update, then when grott becomes available again it will switch back to that method. Right now though I'm focussed on identifying and fixing as many bugs as possible in this integration as the priority. |
With regards to (3) above. I've just made a push to the main branch that reads the value in the MQTT message called NOTE: This requires Grott to be pushing the date/time info correctly, for my SPH system it's not provided in the packets so Grott adds it on it's own. Therefore you have to make sure that grott is running with the correct timezone, by default in a docker container that's UTC, so you need to change the timezone using an environment variable to whatever your local timezone is. |
Works a treat. I've just got a regular HA install on my RPi, so the timezone is all good :) Thanks! |
@Snux - Thanks for the confirmation I'm thinking I may close this ticket once I have confirmation and then add a new issue to update the documentation with info on how to use the add-on as an alternative method. |
Yup, I can indeed confirm that. I'm just using the native Grott -> MQTT from egguy, but with the built in disabled so it's just yours that is supplying my HA sensors. |
@muppet3000 Yes, you can have only the native MQTT messages, or both native + HA compatible MQTT. I also need to find time to update the documentation... |
I'm going to close this one as part of the next release and open a new ticket to update the documentation for people to use the @egguy add-on if they want to. |
Released in v1.1.0 |
For sensors/entities which go back to zero at the start of each day (like export today, generation today etc etc) could you change their state_class from total to total_increasing?
There is some documentation on it here if you're interested :
https://developers.home-assistant.io/docs/core/entity/sensor/
Basically I wanted to try out the standard energy dashboard in HA but it was getting screwed up at midnight when the values dropped back to zero. Using total_increasing tells HA that going back to zero is effectively the start of a new cycle. For the moment I've created template sensors with the new state class but using the values from your integration and that's working fine, but if the base integration could do this I think it would be cleaner. I don't think this would be a breaking change........
The text was updated successfully, but these errors were encountered: