Home assistant...assistance

15 comments started 2022-06-02 last 2022-06-05
APIsHome AutomationHome Assistant
#1 dbt85

Well I'm sitting here getting my butt kicked by a raspberry pi, docker, home assistant, basically the whole lot. For someone that's been building windows machines for people for 27 years now its sad feeling this inept but we are where we are.

Please note. The most I know about APIs is how to spell it. Please explain it like I'm 5 and spend much of my day sucking on my toe.

Anyway, my brother helped me get some of the cloud data into HA with the following inserted into my configuration.yaml using the below

# Example configuration.yaml entry Inv Temps
rest:
scan_interval: 60
resource: https://api.givenergy.cloud/v1/inverter/CE2105xxxx/system-data/latest
headers:
Authorization: Bearer stupidly long api key here
Content-Type: application/json
Accept: application/json
sensor:
- name: "CE2105xxxx Inv Temp"
device_class: temperature
unit_of_measurement: "°C"
value_template: "{{ value_json.data.inverter.temperature }}"

This is all well and good but I have 3 inverters that I want to monitor. If I just copy this block 3 times and make changes, sensors start disappearing. I'd like to add these sensors into a sensors.yaml, however I can't even do something as simple as that on my own.

HA's config validation spits out the following

Invalid config for [sensor]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 8).

line 8 being the one directly above my "sensor: !include sensors.yaml" line in configuration.yaml

Help me Obi Wan Kenobi, you're my only hope before I throw it all out of the window

Don't get me started on givtcp. That's a different argument I'll have with myself in time.

A
#2 anglefire

Givtcp is easy enough to install if you are using docker on a rpi.
Then you can just enable mqtt and read that in HA.

#3 dbt85

anglefire

You say "just enable mqtt" like I say "make sure the secondary events are set to -5 else the recording will fail and you'll have to manually play it in via the evs, make sure to set your routing on the matrix and make sure you check with MCR and S24 before you use one of the externals".

With the greatest respect for all the help you have offered so many in your time on the board, what is easy and simple for one is not the same for another. As I said, I am more computer literate than most of my peers and as yet I have struggled at literally every turn when trying to engage with a Pi, docker, givtcp, portainer, etc etc. Pain in the backside does not come close mostly because I'm fumbling in the dark.

I have, I believe, finally got givTCP at least in a container and set to run on the host network, (again, not immediately obvious how when you ask it to do it and it says no), though not configured or mqtt'd or whatever else needs doing. In a few days I'll be able to get on site (my inverters are only down the road, it's half term and I have other things to do) and try it out and see what it does. My previous attempts on my laptop were 2 hours of fruitlessness.

So, if anyone can help with my initial query in the opening post, even if for my own sanity to get something that should work working, I would appreciate it like you could not possibly believe.

A
#4 anglefire

Ok. Sorry I was a bit flippant.

Where are you currently?
I’m guessing you have got home assistant in a container?
Have you got portainer installed? Not required but does make controlling the containers easier.
Have you got a mqtt broker? You can use givtcp as one - out of the box it is set to be enabled. Otherwise you can add one to home assistant. (The broker is an addin ). No configuration is required.

Either way you get the broker you then need to add the mqtt broker integration.
Configuration is simple - add a user in HA - can be anything but something like mqtt-user keeps it simple. And a password - make it at least 6 characters long (one device I have insists on at least 5!)
Then in the integration add those credentials.

You can test the MQTT broker is working go to the configuration page put a # in the listen box and anything transmitting via MQTT will be visible.

Does any of this make sense?

A
#5 anglefire

As for your initial query I’ll look at it when I’m a bit more awake ! I only have one inverter so will have to try and work it out - though if you can get givtcp working it will be a much more responsive experience.

#6 dbt85

Angelfire. Thanks for your post. I apologise if I was a bit jumpy downy throaty. It's been an annoying few days playing with this. It's not often I feel dumber than a bag of rocks but this has been one of them.

As things stand at this hour, I have my Pi4, docker, docker compose, portainer, HA and now finally mosquitto up and running and talking to HA. Since HA is in a container I can;t use the addons (as far as I can tell) so it wasn't quite as easy as it may have been with HA OS.

I'm not joking when I tell you I've been fiddling with this now for 4 hours tonight, and at least 3 this afternoon and this is as far as I've gotten. Every step forward has felt like 2 steps back with any number of attempts to do things met with issues that didn't appear to be an issue for the guide/walkthrough I was following. Thanks mostly to a chap at homeautomation.io and his youtube channel, I am now where I am.

When I get the chance to try this on site I'll complain wildly in the appropriate thread about how I can;t get it working 😅 At a guess I'll need to run 3 instances as there are 3 inverters but I'll see what pops up.

With regard my initial post. I'm still non the wiser, however what seems quite odd is that if I use the device_class: battery it simply refuses to appear as a sensor. If I change it to just about anything else it appears just fine. Never mind.

Thanks again.

A
#7 anglefire

dbt85 I’ve not forgotten!

There is a function you can call to get the data from multiple inverters in one go. I’m trying to work out the exact format as it needs a body as part of the call to list the inverter serial numbers.

A
#8 anglefire

Well. I’ve been trying for ages to get the inverter temperature using this sensor in yaml. And I can get the sensor to appear but no values. No idea why! Running a similar string in test on the giv energy site works fine.
The format looks to be correct.

I assume you can see the one inverters value ok?

I am
Probably better at helping you get givtcp working if I’m honest!

T
#9 Tim

dbt85 Please explain it like I'm 5 and spend much of my day sucking on my toe.

You know I absolutely recognise this but I don't remember posting! hehe

I spent the most rewarding part of my career working in IT before retiring but have continued to learn the tech, although have no chance of keeping up with all the changes. My approach is that if it can be done, then I can do it. I learnt to program in C++/Python etc, not because I wanted to but because it was what was needed to write firmware for ESP8266s and ESP32s which I use for home automation, running over MQTT. I don't particularly like Docker which is often mooted as the easy/simple option because I don't understand what's going on inside. I would far rather run a python script using cron on my Pi because, when it fails, I can debug the script and understand how to make it do what I want.

Having said that there are some very talented people out there whose skills far exceed mine and I defer to their superior knowledge and expertise. I particularly liked your

dbt85 "make sure the secondary events are set to -5 else the recording will fail and you'll have to manually play it in via the evs, make sure to set your routing on the matrix and make sure you check with MCR and S24 before you use one of the externals"

Now I know how my wife feels when she asks me to explain!! haha 🤣

T
#10 Tim

dbt85 I'll need to run 3 instances as there are 3 inverters

I had difficulties setting up givTCP (I am also a pramatist) and @Britkat who authored the package added a Docker setting for GIVTCPINSTANCE which should be set to 1 for the first inverter and 2 for the second so that they use different TCP ports (6345 and 6346). Whether Mark extended this capability beyond 2 inverters is something that only he can answer. This is an example of someone whose expertise is way beyond mine. One day I will have a go at running ModbusTCP in native python to see if I can replicate the functionality to get the data directly into Node-RED.

#11 dbt85

anglefire Yes I have Inv Temp, Solar output, batt temp and batt charge all on display and working fine, and a socket turning on at inv temp 45 and off at inv temp 40. Once I can do the same with givtcp I can get this all wired in. I found a very useful 5.5x2.1mm jack to 4x fan header cable on amazon that simply needs a little power supply and it can turn the fans on as desired. Hopefully I can also use that data in the energy part of the dashboard but we'll worry about that later.

Tim My approach is that if it can be done, then I can do it.
This is largely my attitude and it rings true for just about everything else. I admit that I cannot just go and perform brain surgery or chair an international committee on the essence of humanity, but largely I can turn my hand to most things. I should have carried on playing with VB 27 years ago aged 10. My brother did aged 7 and he's now all over this stuff doing well for himself (but working way more than I'd like to work haha).

I think what frustrated me most was seeing so many videos or web pages saying "just do this" and me either doing it and it not working, or having no idea how to do that thing (and it being something so basic that I'd be laughed out of sandal wearing linux school for even asking). This is undoubtedly in part because I am attempting to walk before I have stopped drooling into my mushed apple sauce.

As you noted, my example is the perfect window into a world we know nothing about. Once you know what all the apparently English words mean, it all makes sense and you can follow along. Until then you sit there thinking "I know 95% of the words, but in that order it all sounds like complete gobbledegook".

Tim
Thanks for that detail, it will help a great deal and point me in the correct direction.

A
#12 anglefire

anglefire nah thats not going to work - its the way to read/modify the inverter control modes.

A
#13 anglefire

dbt85 I've spent the last hour or so trying to get working what you have working- so I do know your pain!
And its still not working!
I also tried to add a sensor.yaml file to do it in there - that didn't work either (the logic of having an sensor: !include sensor.yaml ) in the configuration.yaml works fine - but doesn't like the rest code in there!

I assume your issue is the second inverter? which you can't display?
In theory I can't see why it doesn't work as long as the sensors are named uniquely. Which they seem to be in your case.
Though you probably don't need to repeat the common headers etc?

#14 dbt85

anglefire I do appreciate your efforts to assist.

In my meagre testing I just duplicated the code from the first post, changed the bits required for the second and third inverters and then let it lose. It seemed to work for a while but then all but one inverters sensors vanished. This I believe is because there would be multiple instances of the "sensor:" (that's the issue that file editor was throwing at me at least).

From my limited understanding, you'd typically have all of your sensors listed under one "sensor:". By having it listed a second time it will apparently just ignore the first one or something and use the last one in the file. Because I need to have a different resource I think I need to have a whole seperate code block, rather than just being able to call that in each -name segment of code, but I'm not really sure.

What baffles me is that "rest" works fine in config.yaml but not in a separate sensor.yaml which is simply spliced into the config (I think).

As I said, its probably moot but I just figured there must be some other way of getting the first lot of sensors working in a sensor.yaml. If I could do that I could get the others working too in their own files perhaps.

No bother. in the next few days I'll get the chance to plug this into the network on site and see what I see with givtcp. I just want to get everything set up that I can before then.

A
#15 anglefire

I tried putting it into a separate sensors file too and had partial success as long as I got rid of the template. I’ve not had chance to investigate but I think you have to have the template then separate from the sensor. Or at least that’s how it seemed to work.