hacompanion icon indicating copy to clipboard operation
hacompanion copied to clipboard

Tempature not shown

Open Bram-diederik opened this issue 2 years ago • 7 comments

I got hacompanion running on my raspberry pi vm server (mouse) and my primary laptop. (Blue-mage)

But tempature is not shown. Perhaps its configuration but i dont see any configuration mentions in the readme. Screenshot_20220811-123201_JuiceSSH Screenshot_20220811-123118_JuiceSSH Screenshot_20220811-121833_Home Assistant

Btw you closed #15 the quote was there because i 1st tryed to run it with out the listener. I think it runs port 80 it there is no configuration so you cant turn off the listener.

Bram-diederik avatar Aug 11 '22 10:08 Bram-diederik

The Regex to parse the cpu temp currently only looks fore core or Package id but not for CPU, this could be easily fixed:

https://github.com/tobias-kuendig/hacompanion/blob/d7b3431aa96bef742700311d0a44c64545c12318/sensor/cpu.go#L19

tobias-kuendig avatar Aug 11 '22 11:08 tobias-kuendig

I fixed this on my Pi with this change

--- a/sensor/cpu.go
+++ b/sensor/cpu.go
@@ -16,7 +16,7 @@ import (
 )
 
 var (
-       reCPUTemp  = regexp.MustCompile(`(?m)(Package id|Core \d)[\s\d]*:\s+.?([\d\.]+)°`)
+       reCPUTemp  = regexp.MustCompile(`(?m)(temp1|Package id|Core \d)[\s\d]*:\s+.?([\d\.]+)°`)
        reCPUUsage = regexp.MustCompile(`(?m)^\s*cpu(\d+)?.*`)
 )
 
@@ -54,7 +54,7 @@ func (c CPUTemp) process(output string) (*entity.Payload, error) {
                if len(match) < 3 {
                        return nil, fmt.Errorf("invalid output form lm-sensors received: %s", output)
                }
-               if strings.EqualFold(match[1], "Package id") {
+               if strings.EqualFold(match[1], "Package id") || strings.EqualFold(match[1], "temp1") {
                        p.State = match[2]
                } else {
                        p.Attributes[util.ToSnakeCase(match[1])] = match[2]

jackyaz avatar Aug 14 '22 19:08 jackyaz

how do i build a go project? i tried go build but that did not work.

Bram-diederik avatar Aug 20 '22 10:08 Bram-diederik

You can try the steps here: https://github.com/jackyaz/hacompanion#installation

Depending on your platform, you may need to install a newer version of Go than provided by your package manager. https://go.dev/doc/install

jackyaz avatar Aug 20 '22 11:08 jackyaz

strange i compiled it for my amd64 it works. but when i crosscompiled it for my PI it did not work. program runs cpu not shown.

Bram-diederik avatar Aug 20 '22 12:08 Bram-diederik

Was that compiling my fork or this one? I didn't cross-compile, I built it on the Pi directly

jackyaz avatar Aug 20 '22 12:08 jackyaz

Did not run on pi correctly due to configuration all is fine now.

Bram-diederik avatar Aug 21 '22 08:08 Bram-diederik

Have this issue on PopOS:

pop-os hacompanion[43608]: 2023/09/25 15:41:13 received Payload for cpu_temp: &{Icon: State:<nil> Attributes:map[]}

JitteryDoodle avatar Sep 25 '23 22:09 JitteryDoodle

Just opened a PR that will probably fix that: #38

pschmitt avatar Nov 04 '23 10:11 pschmitt

fixed in #38

tobias-kuendig avatar Nov 06 '23 07:11 tobias-kuendig