rkosegi / tuya-smartplug-exporter Goto Github PK
View Code? Open in Web Editor NEWPrometheus exporter for Tuya-based smartplug devices
License: Apache License 2.0
Prometheus exporter for Tuya-based smartplug devices
License: Apache License 2.0
Hi, I have just purchased some Tuya smart plugs and am trying to get them connected with this package.
I grabbed my local keys using npx @tuyapi/cli wizard
and setup my config file, but I am getting this error every time I try to scrape
ts=2024-05-10T16:59:24.467Z caller=exporter.go:56 level=warn msg="error during scrape" device=PC error=EOF
ts=2024-05-10T16:59:24.673Z caller=exporter.go:56 level=warn msg="error during scrape" device=AC error=EOF
ts=2024-05-10T16:59:24.867Z caller=exporter.go:56 level=warn msg="error during scrape" device=Server error=EOF
Let me know if there's a way I can get more info and thanks for the help!
EDIT: I've done some tracing and the issue is coming from pkg/proto/client.go
:
func (p *proto) exchange() ([]byte, error) {
// ...
inbuffer := make([]byte, 256)
read, err := conn.Read(inbuffer) // <--
if that helps debug the issue, I'm not very familiar with Go
As I tried setting up the exporter on my Raspberry Pi, the following errors are displayed:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
exec /exporter: exec format error
Having looked into the Github Workflow file publish-image.yaml, this image appears to be only built for AMD64.
I can't promise to find time for it in the next weeks but I'll try to create a small PR with the change to release it on ARM64 and AMD64 if you don't mind.
Hi.
I have been experiencing this error every now and then.
panic: runtime error: slice bounds out of range [:64] with capacity 63
goroutine 214410 [running]:
github.com/rkosegi/tuya-smartplug-exporter/pkg/proto.(*proto).decryptResponse(0xc00009fea8?, {0xc0003e2014, 0x3f, 0xec})
/build/pkg/proto/client.go:93 +0x190
github.com/rkosegi/tuya-smartplug-exporter/pkg/proto.(*proto).Status(0x906a40?)
/build/pkg/proto/client.go:67 +0x6d
github.com/rkosegi/tuya-smartplug-exporter/pkg/exporter.(*exporter).Collect(0xc0001aa000, 0xc00048ff60?)
/build/pkg/exporter/exporter.go:54 +0x2e7
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()
/go/pkg/mod/github.com/prometheus/[email protected]/prometheus/registry.go:455 +0x102
created by github.com/prometheus/client_golang/prometheus.(*Registry).Gather in goroutine 25385
/go/pkg/mod/github.com/prometheus/[email protected]/prometheus/registry.go:466 +0x568
Everything works fine for days but randomly it crashs with the error.
Could't figure out what causes it.
My setup:
I have 3 smart plugs, every plug is 24/7 up except one that might not be reachable for prolonged periods of time but it seams to work fine despite that. Only throws a warning like:
ts=2024-04-27T22:00:28.303Z caller=exporter.go:56 level=warn msg="error during scrape" device=REDACTED error="dial tcp 192.168.9.189:6668: connect: no route to host"
Thanks and sorry for the lack of info.
How could I change the metrics interval? It seens is 10s..
Hi, tried to use your exporter in a container.
The only thing I changed was the default config file to "/config/config.yaml" so I could mount a whole folder.
Honestly I have no idea were to start. Can this be a problem with my config file?
ts=2024-04-02T21:28:51.287Z caller=main.go:76 level=info msg="Starting tuya_smartplug_exporter" version="(version=v1.0.1, branch=HEAD, revision=db4abe8)" config=/config/config.yaml
ts=2024-04-02T21:28:51.288Z caller=main.go:89 level=info msg="Configured 1 devices"
ts=2024-04-02T21:28:51.288Z caller=tls_config.go:313 level=info msg="Listening on" address=[::]:9999
ts=2024-04-02T21:28:51.288Z caller=tls_config.go:316 level=info msg="TLS is disabled." http2=false address=[::]:9999
panic: runtime error: slice bounds out of range [:-86]
goroutine 49 [running]:
github.com/rkosegi/tuya-smartplug-exporter/pkg/proto.unpad(...)
/build/pkg/proto/client.go:111
github.com/rkosegi/tuya-smartplug-exporter/pkg/proto.(*proto).Status(0x906a40?)
/build/pkg/proto/client.go:71 +0xe5
github.com/rkosegi/tuya-smartplug-exporter/pkg/exporter.(*exporter).Collect(0xc0000d2540, 0xc0001ba760?)
/build/pkg/exporter/exporter.go:54 +0x2e7
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()
/go/pkg/mod/github.com/prometheus/[email protected]/prometheus/registry.go:455 +0x102
created by github.com/prometheus/client_golang/prometheus.(*Registry).Gather in goroutine 25
/go/pkg/mod/github.com/prometheus/[email protected]/prometheus/registry.go:466 +0x568
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.