bessarabov / mac2mqtt Goto Github PK
View Code? Open in Web Editor NEWView and control some aspects of macOS computer via MQTT
View and control some aspects of macOS computer via MQTT
panic: runtime error: index out of range [1] with length 0
goroutine 32 [running]:
main.getBatteryChargePercent(0xc000049ef0, 0x1319948)
/Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:284 +0x115
main.updateBattery(0x137cc20, 0xc000198000)
/Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:290 +0x85
main.main.func1(0xc00013a370, 0x137cc20, 0xc000198000, 0xc00013a3c0)
/Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:318 +0xe5
created by main.main
/Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:310 +0x1d0
I've just updated to macOS Ventura today, I'm now getting the following error when trying to execute the mac2mqtt file:
conor@Conors-MacBook-Pro mac2mqtt % ./mac2mqtt
2022/10/25 13:26:29 Started
2022/10/25 13:26:29 Connected to MQTT
2022/10/25 13:26:29 Sending 'true' to topic: mac2mqtt/Conors-MacBook-Pro/status/alive
2022/10/25 13:26:31 strconv.Atoi: parsing "missing value": invalid syntax
See the discrussion starting from https://community.home-assistant.io/t/mac2mqtt-control-volume-on-macos-via-mqtt/298607/14
mac2mqtt 1.3.1 running on 11.5.2 doesn't launch on boot even with KeepAlive and RunAtLoad enabled in /Library/LaunchDaemons/com.bessarabov.mac2mqtt.plist. It doesn't run unless i manually run launchctl load /Library/LaunchDaemons/com.bessarabov.mac2mqtt.plist
Console shows Aug 31 10:32:24 Mac com.apple.xpc.launchd[1] (com.bessarabov.mac2mqtt[8205]): Service exited with abnormal code: 2
every minute.
What else can I check? Thanks.
Hello,
I am interested in this software just to shutdown remotely via Home Assistant, but I am running into several problems.
Let's start in the first one.
I edited the files in order to reflect my username, but when mac2mqtt is running, it terminates itself after a while using "bessarabov" absolute username.
I thinks this is in the program itself and not in my YAML files.
What is it trying to do accessing a Dropbox directory?
Have I forget to change somewhere?
Can you please help me?
<-user->@<-computer-> mac2mqtt % ./mac2mqtt
2022/11/22 09:45:51 Started
2022/11/22 09:45:51 Connected to MQTT
2022/11/22 09:45:51 Sending 'true' to topic: mac2mqtt/<-computer->/status/alive
panic: runtime error: index out of range [1] with length 0goroutine 45 [running]:
main.getBatteryChargePercent(0xc00004fef0, 0x1319948)
/Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:284 +0x115
main.updateBattery(0x137cc20, 0xc000120000)
/Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:290 +0x85
main.main.func1(0xc0001a6000, 0x137cc20, 0xc000120000, 0xc0001a6050)
/Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:318 +0xe5
created by main.main
/Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:310 +0x1d0
<-user->@<-computer-> mac2mqtt %
Hi, I am not a Go person.
Getting the following error while running $ go run mac2mqtt.go
mac2mqtt % go run mac2mqtt.go package command-line-arguments imports gopkg.in/yaml.v2 imports gopkg.in/yaml.v2: import cycle not allowed
Hello,
I don't know if anyone is having this issue.
Here is a list of how mqtt alive property changes when my macmini is on:
21/6/2023, 9:18:17 node: ISOFF debug 117 mac2mqtt/Mac-mini-de-Fernando/status/alive: msg.payload : boolean true 21/6/2023, 9:18:30 node: ISOFF debug 117 mac2mgtt/Mac-mini-de-Fernando/status/alive msg.payload : boolean false 21/6/2023, 9:18:30 node: ISOFF debug 117 mac2mgtt/Mac-mini-de-Fernando/status/alive: msg.payload : boolean true 21/6/2023, 9:19:31 node: ISOFF debug 117 mac2mqtt/Mac-mini-de-Fernando/status/alive: msg.payload : boolean false 21/6/2023, 9:19:31 node: ISOFF debug 117 mac2mqtt/Mac-mini-de-Fernando/status/alive: msg.payload: boolean true
and here a list of when computer is off:
21/6/2023, 9:05:27 node: ISOFF debug 117 mac2mqtt/Mac-mini-de-Fernando/status/alive msg.payload: boolean false 21/6/2023, 9:09:45 node: ISOFF debug 117 mac2mqtt/Mac-mini-de-Fernando/status/alive mga. pavload : boolean true 21/6/2023, 9:11:09 node: ISOFF debug 117 mac2mqtt/Mac-mini-de-Fernando/status/alive msg.payload: boolean false 21/6/2023, 9:15:30 node: ISOFF debug 117 mac2mqtt/Mac-mini-de-Fernando/status/alive msg.payload : boolean true 21/6/2023, 9:15:32 node: ISOFF debug 117 mac2mgtt/Mac-mini-de-Fernando/status/alive msg.payload: boolean false 21/6/2023, 9:15:32 node: ISOFF debug 117 mac2mqtt/Mac-mini-de-Fernando/status/alive msg.payload: boolean true 21/6/2023, 9:16:51 node: ISOFF debug 117 mac2matt/Mac-mini-de-Fernando/status/alive msg.payload: boolean false
I don't know how this is so erratic for me.
Any thoughts?
Thanks in advance
Hallo Ivan,
is it possible that you release your code with under an open source license?
Yours
Christoph
with
goroutine 20 [running]: main.getBatteryChargePercent(0xc00006eef0, 0x1319948) /Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:284 +0x115 main.updateBattery(0x137cc20, 0xc0000fc000) /Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:290 +0x85 main.main.func1(0xc00008e3c0, 0x137cc20, 0xc0000fc000, 0xc00008e410) /Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:318 +0xe5 created by main.main /Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:310 +0x1d0
M2M 1.3.1 on Big Sur 11.5.2
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.