Code Monkey home page Code Monkey logo

tuya-smartplug-exporter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tuya-smartplug-exporter's Issues

Error during scrape

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

Image does not work on ARM64 architecture

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.

Runtime Error - Slice bounds out of range

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.

Runtime error after a single request to :9999/metrics

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.