ztalbot2000 / homebridge-cmd4 Goto Github PK
View Code? Open in Web Editor NEWCMD4 Plugin for Homebridge - Supports ~All Accessory Types & now all Characteristics too
License: Apache License 2.0
CMD4 Plugin for Homebridge - Supports ~All Accessory Types & now all Characteristics too
License: Apache License 2.0
Hello!
How to use CMD4 with https://github.com/Andrey-m/homebridge-redmond-sh ?
Thanks in advance.
Hello!
It's sophisticated for me to migrate from cmdswitch to your plugin.
I'm using .sh scripts in state_cmd, on_cmd and off_cmd, for example:
"on_cmd": "sudo /home/pi/on.sh MAC on",
"off_cmd":` "sudo /home/pi/off.sh MAC off",
"state_cmd": "sudo /home/pi/status.sh MAC | grep -l 'ON'"
Is it possible to link in your state_cmd
my on.sh, off.sh and status.sh
?
Probably you can help with solution of my problem.
Thanks in advance,
Maxim.
First of all, thanks for all the great work done so far!
I'm using this plugin to control many different devices, including some shutters. Setting the shutters works fine, however the CurrentPosition value does not seem to be displayed correctly in the Home app. It looks fine in when the script is executed manually though:
/homebridge # sh /homebridge/Cmd4Scripts/franken.sh Set example_shutter TargetPosition 10
202
/homebridge # sh /homebridge/Cmd4Scripts/franken.sh Get example_shutter PositionState
2
/homebridge # sh /homebridge/Cmd4Scripts/franken.sh Get example_shutter CurrentPosition
10
The above example results in 1% shown in the app (instead of 10%).
Tried setting up PS4. When testing PS4.sh using command line the device on and off code doesn't do anything. However getting the device status works.
Hey,
first of all thanks for this great plugin!
Sadly I'm kinda stuck at the moment... in your readme you said I'd have to put the State.js file in ~/.homebridge/Cmd4Scripts but I'm running Homebridge as systemd service and my main directory (which contains the config.json etc) are located at /var/homebridge so I put my Cmd4Scripts folder with the State.js file in there... I just tested my first On/Off script but I'm not sure if it doesn't work as expected because I made a mistake in the script or if the state.js file doesn't work because it's in the right place.
I hope my question is no duplicate.
Thanks in advance,
Niko :)
Will this plugin work with telnet commands? Many thanks!
Just wanted to let you know that the NPM readme contains old instructions, I was halfway through it when I discovered that it was referring to an old version titled homebridge-cmd.
I get a "No Response" error in the Home app whenever I add polling to my config.json for either a door or a motinon sensor.
I've implemented polling on a Door as it is outlined in the Cmd4 Extras config.json:
{
"type": "Door",
"name": "My_Door",
"currentPosition": 0,
"targetPosition": 0,
"positionState": 0,
"polling": [{"statusActive": 1, "interval": 80, "timeout":1000},
{"statusFault" : 10, "interval": 50, "timeout":2000}
],
"stateChangeResponseTime": 3,
"state_cmd": "python ~/.homebridge/Cmd4Scripts/back_door_state.py"
}
It works just fine without polling. But whenever I add polling it breaks.
Here's the homebridge log for when I add polling...seems like the script fails to execute whenever I add polling, but this same error isn't present when I remove polling:
0|homebridge | [5/7/2019, 9:57:44 AM] [Cmd4] getGeneric TargetPosition function for: Back Door cmd: python ~/.homebridge/Cmd4Scripts/back_door_state.py Get 'Back Door' 'TargetPosition' failed.
0|homebridge | [5/7/2019, 9:57:44 AM] [Cmd4] { Error: Command failed: python ~/.homebridge/Cmd4Scripts/back_door_state.py Get 'Back Door' 'TargetPosition'
0|homebridge | at ChildProcess.exithandler (child_process.js:294:12)
0|homebridge | at ChildProcess.emit (events.js:189:13)
0|homebridge | at maybeClose (internal/child_process.js:970:16)
0|homebridge | at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
0|homebridge | killed: true,
0|homebridge | code: null,
0|homebridge | signal: 'SIGTERM',
0|homebridge | cmd:
0|homebridge | 'python ~/.homebridge/Cmd4Scripts/back_door_state.py Get \'Back Door\' \'TargetPosition\'' }
0|homebridge | [5/7/2019, 9:57:44 AM] [Cmd4]
0|homebridge | [5/7/2019, 9:57:44 AM] [Cmd4]
0|homebridge | [5/7/2019, 9:57:44 AM] [Cmd4] getGeneric CurrentPosition function for: Back Door cmd: python ~/.homebridge/Cmd4Scripts/back_door_state.py Get 'Back Door' 'CurrentPosition' failed.
0|homebridge | [5/7/2019, 9:57:44 AM] [Cmd4] { Error: Command failed: python ~/.homebridge/Cmd4Scripts/back_door_state.py Get 'Back Door' 'CurrentPosition'
0|homebridge | at ChildProcess.exithandler (child_process.js:294:12)
0|homebridge | at ChildProcess.emit (events.js:189:13)
0|homebridge | at maybeClose (internal/child_process.js:970:16)
0|homebridge | at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
0|homebridge | killed: true,
0|homebridge | code: null,
0|homebridge | signal: 'SIGTERM',
0|homebridge | cmd:
0|homebridge | 'python ~/.homebridge/Cmd4Scripts/back_door_state.py Get \'Back Door\' \'CurrentPosition\'' }
0|homebridge | [5/7/2019, 9:57:44 AM] [Cmd4]
0|homebridge | [5/7/2019, 9:57:44 AM] [Cmd4]
Hi, I have to say I haven't had a close enough look yet to tell if you have, but...
So that the user can still pick the same type of device name they'd choose with regular homekit devices. Because imho the requirement of underscores in device names is a very unfortunate shortcoming, given the fact that the overall features in this project seem very promising.
Hi,
I want to run a .sh file, but I always get this error:
Apr 06 01:34:31 raspberrypi homebridge[6956]: [2019-4-6 01:34:31] [Cmd4] Cmd4 getGeneric On function for: PiHole cmd: bash /var/homebridge/cmd4/pihole.sh Get 'PiHole' 'On' failed.
Apr 06 01:34:31 raspberrypi homebridge[6956]: [2019-4-6 01:34:31] [Cmd4] { Error: Command failed: bash /var/homebridge/cmd4/pihole.sh Get 'PiHole' 'On'
Apr 06 01:34:31 raspberrypi homebridge[6956]: /var/homebridge/cmd4/pihole.sh: Zeile 7: Syntaxfehler beim unerwarteten Wort newline' Apr 06 01:34:31 raspberrypi homebridge[6956]: /var/homebridge/cmd4/pihole.sh: Zeile 7:
'
Apr 06 01:34:31 raspberrypi homebridge[6956]: at ChildProcess.exithandler (child_process.js:281:12)
Apr 06 01:34:31 raspberrypi homebridge[6956]: at emitTwo (events.js:126:13)
Apr 06 01:34:31 raspberrypi homebridge[6956]: at ChildProcess.emit (events.js:214:7)
Apr 06 01:34:31 raspberrypi homebridge[6956]: at maybeClose (internal/child_process.js:915:16)
Apr 06 01:34:31 raspberrypi homebridge[6956]: at Socket.stream.socket.on (internal/child_process.js:336:11)
Apr 06 01:34:31 raspberrypi homebridge[6956]: at emitOne (events.js:116:13)
Apr 06 01:34:31 raspberrypi homebridge[6956]: at Socket.emit (events.js:211:7)
Apr 06 01:34:31 raspberrypi homebridge[6956]: at Pipe._handle.close [as _onclose] (net.js:561:12)
Apr 06 01:34:31 raspberrypi homebridge[6956]: killed: false,
Apr 06 01:34:31 raspberrypi homebridge[6956]: code: 2,
Apr 06 01:34:31 raspberrypi homebridge[6956]: signal: null,
Apr 06 01:34:31 raspberrypi homebridge[6956]: cmd: 'bash /var/homebridge/cmd4/pihole.sh Get 'PiHole' 'On'' }
Apr 06 01:34:31 raspberrypi homebridge[6956]: [2019-4-6 01:34:31] [Cmd4]
Apr 06 01:34:31 raspberrypi homebridge[6956]: [2019-4-6 01:34:31] [Cmd4] /var/homebridge/cmd4/pihole.sh: Zeile 7: Syntaxfehler beim unerwarteten Wort newline' Apr 06 01:34:31 raspberrypi homebridge[6956]: /var/homebridge/cmd4/pihole.sh: Zeile 7:
'
The pihole.sh file looks like this:
#!/bin/bash
if [ "$1" = "Get" ]; then
state=$(pihole status | grep -c Enabled)
if [[ "$state" = "0" ]]; then
echo "$state"
exit 0
elif [[ "$state" = "1" ]]; then
echo "$state"
exit 0
fi
fi
if [ "$1" = "Set" ]; then
if [ $4 = true ]; then
pihole enable
exit $?
elif [ $4 = false ]; then
pihole disable
exit $?
fi
fi
exit -1
And my config.json looks like this:
{
"platform": "Cmd4",
"name": "Cmd4",
"accessories": [
{
"type": "Switch",
"name": "PiHole",
"on": false,
"polling": true,
"interval": 5,
"timeout": 2000,
"state_cmd": "bash /var/homebridge/cmd4/pihole.sh"
}
]
},
Does anyone see where the issue is?
Thanks in advance!
is there a way to set the range of temperatures in a temperature sensor? right now on my HomeKit app it clamps between 32 and 212 when I see the temperature sensor in the iOS app, even though I'm sending back negative floating point values for "CurrentTemperature" requests.
I'm actually using the temperature sensor for another purpose, it's a power meter for my electric vehicle charger. it seems to be the best sensor for the purpose (just to report a floating point value so I can see how much power the EV is pulling when it is plugged in)
Could someone please give me a hint how to use the TLV8 characteristics within the Television accessory? I have a Grundig TV with a single HDMI input from a Raspberry Pi running Kodi (passed through a denon receiver).
RasPi --(HDMI)--> Denon --(HDMI)--> TV
With this awesome homebridge plugin I have already implemented the following using only one Television accessory:
Now I try to implement the functionality of the iOS built in Remote App to control my Kodi on Raspberry Pi for:
My problem is, that I do not understand how to activate/enable the TLV8 options. What does the "... unless 'allowTLV8' is set, at your own peril." mean? I used it in config.json within my Television accessory but nothing happens.
I hope someone can point me in the right direction.
Thanks in advance.
Michael
Hi,
At first I want to say thank You for this module. It's great!
I have problem with GarageDoorOpener.
Two problems:
My garage doors (default closed) is saying "Opening..." after fresh Homebridge start. CurrentDoorState returning right value (1, as doors are closed). Something is wrong with TargetDoorState. Any ideas?
I have another gate, that is working similar to garage doors, but is auto-closing after some interval of time. I write some bash scripts to operate this gate using Cmd4 and everything is working smooth, but after auto-closing (again, as above - CurrentDoorState returning right value - 1 - as gate is closed) gate switch to "Opening..." state.
Please, help. I'm out of ideas digging in sources and analyzing HomeKit SDK.
Thanks!
Fascinating plugin! I'm keen to see if I can create some fake, triggerable Motion Sensors in order to get some push notifications.
Have installed, then installed State.js, and plucked the relevant config for the devices out of config.json. It all initialises without error, but as soon as I view anything in Home.app, homebridge try to run State.js, and fails continuously with errors like these:
[7/24/2018, 7:39:09 PM] [Cmd4] Cmd4 getGeneric On function for: My_OnOff_Light cmd: node .homebridge/Cmd4Scripts/State.js Get 'My_OnOff_Light' 'On' failed.
[7/24/2018, 7:39:09 PM] [Cmd4] { Error: Command failed: node .homebridge/Cmd4Scripts/State.js Get 'My_OnOff_Light' 'On'
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module '/.homebridge/Cmd4Scripts/State.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:240:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:564:3)
at ChildProcess.exithandler (child_process.js:291:12)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:961:16)
at Socket.stream.socket.on (internal/child_process.js:380:11)
at Socket.emit (events.js:182:13)
at Pipe._handle.close (net.js:595:12)
killed: false,
code: 1,
signal: null,
cmd:
'node .homebridge/Cmd4Scripts/State.js Get \'My_OnOff_Light\' \'On\'' }
[7/24/2018, 7:39:09 PM] [Cmd4]
[7/24/2018, 7:39:09 PM] [Cmd4] internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module '/.homebridge/Cmd4Scripts/State.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:240:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:564:3)
The error is seemingly "cannot find module". So, I tried just running State.js by itself in Terminal from the homebridge user's home directory, but I get a different error:
$ node .homebridge/Cmd4Scripts/State.js Set 'My_ContactSensor' 'ContactSensorState' 0
fs.js:141
throw new ERR_INVALID_CALLBACK();
^
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at makeCallback (fs.js:141:11)
at Object.mkdir (fs.js:720:16)
at Object.<anonymous> (/Users/anyone/.homebridge/Cmd4Scripts/State.js:77:4)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:240:19)
How do i use the television? I want to be able to switch inputs and turn it on and off with an command.
SyntaxError: Unexpected token A in JSON at position 0
at JSON.parse ()
at IncomingMessage.res.on (/usr/local/lib/node_modules/homebridge-cmd4/node_modules/github-version-checker/lib/check.js:64:21)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
When homebridge-cmd4 is installed in oznu/homebridge Docker Container i get the upper error message right after activating the first accessory. This happens nearly all the time, but in rare cases i managed to get it working, but i did not know why. My config.json is absolutely without errors.
That behavior was not the case in the past. I tried to use previous version 2.2.1 with rare success. I also tried to use newest Docker image of homebridge. Nothing helped. In the cases when it works a single restart sometimes is enough to break my installation by this error. Actually i spent hours to investigate with no success.
And finally i did not find any solution on Google.
Please help.
Does this plugin allow us to run PowerShell commands? I have homebridge installed on both Windows and Ubuntu. Both support PowerShell. Is there a way to run PowerShell commands/scripts allowing me to control different things?
/usr/lib/node_modules/homebridge-cmd4/index.js:1354
if (characteristicStrincharacteristicString == "TargetTemperature")
^
ReferenceError: characteristicStrincharacteristicString is not defined
at /usr/lib/node_modules/homebridge-cmd4/index.js:1354:19
at ChildProcess.exithandler (child_process.js:267:7)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
Hi,
Thank you for the great effort you put in to build the CMD4 accessory. I would appreciate your feedback on the following error I am receiving.
On and OFF states/ commands execute fine however, the status is not cooperating. At pooling time, I am getting the warning message below and the switch turns OFF
[4/9/2020, 10:49:25 AM] [Cmd4] Warning, Retrieving On, expected only one word value for:TV, using first of:2 packets transmitted, 2 received, 0% packet loss, time 17ms
true
I have tried a lot of iteration to get the status of the device but all give me same results.
### Homebridge-cmd4 will interpret the result of false to be 1
### and true to be 0 so either 0/1 or true/false can be returned.
ping -c 2 -W 1 192.168.1.110 | grep -i '2 received' > null && (echo "true") || (echo "false")
My current switch bash script is as following:
#!/bin/bash
if [ ! -f "/tmp/fileVariableHolder" ]; then
echo "0" > "/tmp/fileVariableHolder"
fi
if [ "$1" = "Get" ]; then
ping -c 2 -W 1 192.168.1.110 | grep -i '2 received'
cat /tmp/fileVariableHolder
rc=$?
if [ "$rc" = "0" ]; then
exit 0
else
echo "failed"
exit -1
fi
fi
.
.
.
Much appreciated
iOS 12 adds support for viewing decimal temperatures in Home. When I pass a decimal temperature to a cmd4 accessory it always rounds down. For reference, homebridge-dht22 does not round and shows decimal temperatures in Home.
CarbonDioxideDetected
works in my Home.app, but carbonDioxideLevel
are not displayed.
Am I wrong?
This is part of a config.txt.
{
"type": "CarbonDioxideSensor",
"name": "CO2",
"carbonDioxideDetected": 0,
"carbonDioxideLevel": 0,
"polling": false,
"interval": 540,
"stateChangeResponseTime": 3,
"state_cmd": "ruby ~/.homebridge/cmd4.rb"
},
This is part of a ruby script.
mode, acs_name, chara, value = ARGV
case acs_name
when "CO2"
field = "co2"
ppm = current_value(field,location)
case chara
when "CarbonDioxideDetected"
puts ppm > 1000 ? 1 : 0
when "CarbonDioxideLevel"
puts ppm
end
exit
Thank you for the great repository!
Cmd4 Warning: Unknown characteritic 'On' to update for accessory 'Server'
That's the error spammed in log. This was working up til about a couple weeks ago. I didnt change anything so i can only assume an update broke it.
config.json
{
"platform": "Cmd4",
"name": "Cmd4",
"accessories": [
{
"type": "Switch",
"name": "Server",
"on": false,
"state_cmd": "sh /homebridge/Server.sh",
"polling": true,
"interval": 5,
"timeout": 2000
}
]
}
Server.sh
#!/bin/sh
if [ "$1" = "Get" ]; then
# $2 would be the name 'PS4'
# $3 would be the charactersistic 'On'
ping -c 2 -W 1 192.168.1.90 | grep -i '2 packets received' >> /dev/null
rc=$?
if [ "$rc" = "0" ]; then
echo "1"
exit 0
else
echo "0"
exit 0
fi
fi
if [ "$1" = "Set" ]; then
# $2 would be the name 'PS4'
# $3 would be the the charactersistic 'On'
# $4 would be '0' for 'On' and '1' for 'Off'
if [ "$4" = "true" ]; then
curl localhost:3001/api/commands/run/server_on
exit $?
fi
if [ "$4" = "false" ]; then
curl localhost:3001/api/commands/run/server_off
exit $?
fi
fi
exit -1
Hi there,
I just tested your plugin and got the string values true
/false
passed for the On
characteristic instead of 0
/1
like described in the README.
You might want to fix this.
Best regards
CoAP Server no cached entry found
Hi, can I have Thermostat that only supports heating. Can I disable the cooling mode and hide it in the home app?
I have seen HomeKit devices that have only heating mode in home app.
Hi there,
We've noticed your plugin is using homebridge
as a prod-dependency.
Homebridge should only be included in plugins as a dev-dependency and used for TypeScript types.
In the next release of we are changing Homebridge to only export types and const enums which can be safely used in your code and not result in Homebridge becoming a runtime dependency.
You can test this out using the current beta of Homebridge:
npm install --save-dev homebridge@beta
Hi,
GREAT PLUGIN!!! Thank you!
I have only one problem,
when I update a status,
for example the status of my door with the
/usr/local/bin/node /Users/user01/.homebridge/Cmd4Scripts/State.js Set Door TargetPosition 100
it work well but I have to open the Home App on my iPhone to update the door status.
So in this way a never have the alert.
Is my config problem or some bug?
Thank you!!
Hi trying to add tv to the plugin just need on, off , state , through url or curl
Thanks
Hi there,
I noticed a short delay after e.g. switching on/off a switch. The HomeKit app shows a small rotating gear after pressing the button and Siri says something like "checking your home ..." after performing an action. The action is executed nearly instant tho. It's just like the homebridge/cmd4 takes some time to report the result back to the HomeKit app.
Did not have this behavior with the cmdswitch2
plugin which I used before changing to cmd4
. The initial status check after opening the HomeKit app takes longer as well.
Is there anything I can do about that?
Best regards
The requested platform 'config' was not registered by any plugin.
I have homebridge working and all the state.js stuff working but I am getting some errors when I run it. Here they are.
[2/24/2019, 6:06:07 PM] Loaded config.json with 1 accessories and 1 platforms.
[2/24/2019, 6:06:07 PM] ---
[2/24/2019, 6:06:07 PM] Plugin /usr/local/lib/node_modules/homebridge-cmd4 requi4.0.0. You may need to upgrade your installation of Node.
[2/24/2019, 6:06:07 PM] Loaded plugin: homebridge-cmd4
[2/24/2019, 6:06:07 PM] Registering accessory 'homebridge-cmd4.Cmd4'
[2/24/2019, 6:06:07 PM] Registering platform 'homebridge-cmd4.Cmd4'
[2/24/2019, 6:06:07 PM] ---
[2/24/2019, 6:06:07 PM] Loading 1 platforms...
[2/24/2019, 6:06:07 PM] [Cmd4] Initializing Cmd4 platform...
[2/24/2019, 6:06:07 PM] [Cmd4] Cmd4:Fetching config.json devices.
[2/24/2019, 6:06:07 PM] [Cmd4] Cmd4:Found PS4
[2/24/2019, 6:06:07 PM] [Cmd4] Initializing platform accessory 'PS4'...
[2/24/2019, 6:06:07 PM] Loading 1 accessories...
/usr/local/lib/node_modules/homebridge/lib/api.js:50
if (name.indexOf('.') == -1) {
^
TypeError: Cannot read property 'indexOf' of undefined
at API.accessory (/usr/local/lib/node_modules/homebridge/lib/api.js:50:11)
at Server.str.replace.Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:286:42)
at Server.str.replace.Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:87:38)
at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:45:10)
at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
I dont know how to fix it. Please help.
Hi, I added some motion sensors and enable notifications for them. They work if the Home app is open, because when I open the app all the sensors are updated. How can I automatically update the added motion sensor with cmd4 in the background so that I always receive notifications?
I'm trying to set up the volume on my Kodi box as a virtual speaker (I use Kodi's built-in volume control on a dumb speaker system), but I'm having a hard time wrapping my head around how to go about it.
In my JSON, I have:
{
"platform": "Cmd4",
"name": "Cmd4",
"accessories": [
{
"type": "Speaker",
"displayName": "Kodi",
"mute": "0",
"volume": 5,
"name": "Kodi",
"stateChangeResponseTime": 3,
"state_cmd": "bash /var/lib/homebridge/scripts/kodivolume.sh"
}
]
},
and the kodivolume.sh script is as follows:
#!/usr/bin/env bash
if [ "$1" = "Get" ]; then
if [ "$3" == "Volume" ] || [ "$3" == "Mute" ]; then
#get volume/muted info using curl
getinfo=$(curl -s -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": [ "volume","muted" ] }, "id": 1 }' http://192.168.0.112:8080/jsonrpc )
#parse the JSON for information
kodivolume=$(jq -r '.result.volume' <<<"$getinfo")
kodimuted=$(jq -r '.result.muted' <<<"$getinfo")
if [ "$3" == "Volume" ]; then
echo "$kodivolume"
exit 0
else
if [[ "$kodimuted" == "true" ]]; then
echo 1
exit 0
else
echo 0
exit 0
fi
fi
fi
fi
if [ "$1" = "Set" ] && [ "$3" == "Volume" ]; then
#check if variable #4 exists, and that it is indeed a number (with optional percent sign)
if [ ! -z "$4" ] && [[ "$4" =~ ^[0-9]{1,2}%*$ ]]; then
json='{"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":%s},"id":1}'
#filter out everything but the number
number=${4//[!0-9]}
#Join number to JSON string
jsonstring=$(printf "$json" "$number")
#Call JSON
curl -s -H 'Content-Type: application/json' -d $jsonstring http://192.168.0.112:8080/jsonrpc
exit 0
else
exit -1
fi
echo 1
exit 0
fi
exit -1
If feels like this should work, but I'm new to homebridge.
[Edited to update with newer script, but it's still not working]
is there way for cmd4 to have thermostat accessory that has only 3 func heat cold off on http post commands ?
thanks
the plugin worked well for me until I restart homebridge and could not get it run again. Found this in the log:
SyntaxError: Unexpected token A in JSON at position 0 Oct 10 10:46:42 raspberrypi homebridge[27444]: at JSON.parse (:null:null) Oct 10 10:46:42 raspberrypi homebridge[27444]: at IncomingMessage.res.on (/var/homebridge/node_modules/homebridge-cmd4/node_modules/github-version-checker/lib/check.js:64:21)
I had to downgrade to version 2.1 and it works well
Hey please could you point me in the right direction of how to add a command that would be performed when an accessory is controlled as I can't see anything about it in your README.
Thanks for your help, David
First of all - HUGE thank you for this plugin!!! I successfully connected my dumb aircon wi-fi controller and Oregon BLE weather station to HomeKit using simple bash scripts
This issue is to ask you to please consider integrating support for fakegato-history to be used with temperature/humidity sensors
This module saves a log with temp/humidity values and exposes it to Eve app. The app draws very nice graphs so you can see historical values
https://www.npmjs.com/package/fakegato-history
Thank you again!
Hi guys, I am trying to install homebridge-cmd4 link:https://www.npmjs.com/package/homebridge-cmd4, but I am hold on step3.
I first created mkdir .homebridge/Cmd4Scripts
then cp State.js .homebridge/Cmd4Scripts/State.js
But tell me it is a invalit file or directory.....
How Can I issue it?
Hi there!
I really appreciate the work you've put into this plugin as it's made adding different types of accessories far easier and customisable. However, I'm having one slight problem which I'm hoping you could help me out with. I've managed to add a number of accessories to my home app which is great but where in the config.json file I've put both an "on_cmd": "<executable>"
and an "off_cmd": "<executable>"
with <executable>
being the command I wish the accessory to carry out but so far this does nothing. Despite the fact that when I click the accessory in the app and it correctly changes state to show either on or off, it does not actually carry out the respective command.
I apologise if the solution is glaringly obvious but would really appreciate it if someone could point me in the right direction to have the accessory actually carry out a command.
Thank you in advance,
Tom
Raspberry Pi 3, debian 10.0
I get errors after migrating to homebridge 1.0.4. Most other plugins still work, cmd4 fails when launching any of my scripts, e.g.
[06/05/2020, 17:14:28] [Cmd4] getGeneric On function for:Alarm cmd:node /var/homebridge/Cmd4Scripts/Alarm.js Get 'Alarm' 'On' failed.
[06/05/2020, 17:14:28] [Cmd4] { Error: Command failed: node /var/homebridge/Cmd4Scripts/Alarm.js Get 'Alarm' 'On'
at ChildProcess.exithandler (child_process.js:294:12)
at ChildProcess.emit (events.js:198:13)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
killed: true,
code: null,
signal: 'SIGTERM',
cmd:
'node /var/homebridge/Cmd4Scripts/Alarm.js Get \'Alarm\' \'On\'' }
Hi, I was wondering if any of the fan accessories in cmd4 accommodate a fan that has speeds low, medium high and auto? I have not been able to find out whether Homekit itself allows this, so no doubt it is a limitation of Homekit if anything :) If so can you show me how the config would differ from the example already in your sample config? Thanks in advance :)
I'm trying to get a door sensor set up by using data returned from the py-august api for my August door locks. When I run the script in my shell I correctly get a 1 or 0 for open
or closed
state. But, when I add it to my config.json the Home app shows the device with a "No Response" error.
Here's my the portion of my config.json file for the door sensor:
{
"platform": "Cmd4",
"name": "Cmd4",
"accessories":
[
{
"type": "Door",
"name": "Front Door",
"currentPosition": 0,
"targetPosition": 0,
"positionState": 0,
"stateChangeResponseTime": 3,
"state_cmd": "python ~/.homebridge/Cmd4Scripts/front_door_state.py"
}
]
}
Here's the python script returning the state values:
#!/home/pi/berryconda3/bin/python
import sys
from august.api import Api
from august.authenticator import (
Authenticator, AuthenticationState, ValidationResult)
import requests
user_name = '<PHONE NUMBER>'
password = '<PASSWORD>'
use_session = True
combine_status = True
api = Api(timeout=20)
authenticator = Authenticator(api, "phone", user_name, password,
access_token_cache_file=".august.conf")
authentication = authenticator.authenticate()
locks = api.get_operable_locks(authentication.access_token)
front_lock_status = api.get_lock_status(authentication.access_token,'BF4F854D9E9B4786A9FA3A8833AAE09A')
front_door_status = api.get_lock_door_status(authentication.access_token,'BF4F854D9E9B4786A9FA3A8833AAE09A')
back_lock_status = api.get_lock_status(authentication.access_token,'41C161F1D5DB4C30948CE8184C8438F1')
back_door_status = api.get_lock_door_status(authentication.access_token,'41C161F1D5DB4C30948CE8184C8438F1')
open = "LockDoorStatus.OPEN"
closed = "LockDoorStatus.CLOSED"
def frontDoorState():
if str(front_door_status) == open:
print(0)
elif str(front_door_status) == closed:
print(1)
frontDoorState()
Here are some of the error logs I'm getting from homebridge:
0|homebridge | [5/6/2019, 4:05:03 PM] [Cmd4] getGeneric StatusActive function for: Front Door cmd: python ~/.homebridge/Cmd4Scripts/front_door_state.py Get 'Front Door' 'StatusActive' failed.
0|homebridge | [5/6/2019, 4:05:03 PM] [Cmd4] { Error: Command failed: python ~/.homebridge/Cmd4Scripts/front_door_state.py Get 'Front Door' 'StatusActive'
0|homebridge | at ChildProcess.exithandler (child_process.js:294:12)
0|homebridge | at ChildProcess.emit (events.js:189:13)
0|homebridge | at maybeClose (internal/child_process.js:970:16)
0|homebridge | at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
0|homebridge | killed: true,
0|homebridge | code: null,
0|homebridge | signal: 'SIGTERM',
0|homebridge | cmd:
0|homebridge | 'python ~/.homebridge/Cmd4Scripts/front_door_state.py Get \'Front Door\' \'StatusActive\'' }
0|homebridge | [5/6/2019, 4:05:03 PM] [Cmd4]
0|homebridge | [5/6/2019, 4:05:03 PM] [Cmd4]
0|homebridge | [5/6/2019, 4:05:13 PM] [Cmd4] getGeneric StatusFault function for: Front Door cmd: python ~/.homebridge/Cmd4Scripts/front_door_state.py Get 'Front Door' 'StatusFault' failed.
0|homebridge | [5/6/2019, 4:05:13 PM] [Cmd4] { Error: Command failed: python ~/.homebridge/Cmd4Scripts/front_door_state.py Get 'Front Door' 'StatusFault'
0|homebridge | at ChildProcess.exithandler (child_process.js:294:12)
0|homebridge | at ChildProcess.emit (events.js:189:13)
0|homebridge | at maybeClose (internal/child_process.js:970:16)
0|homebridge | at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
0|homebridge | killed: true,
0|homebridge | code: null,
0|homebridge | signal: 'SIGTERM',
0|homebridge | cmd:
0|homebridge | 'python ~/.homebridge/Cmd4Scripts/front_door_state.py Get \'Front Door\' \'StatusFault\'' }
0|homebridge | [5/6/2019, 4:05:13 PM] [Cmd4]
0|homebridge | [5/6/2019, 4:05:13 PM] [Cmd4]
0|homebridge | [5/6/2019, 4:06:03 PM] [Cmd4] getGeneric StatusFault function for: Front Door cmd: python ~/.homebridge/Cmd4Scripts/front_door_state.py Get 'Front Door' 'StatusFault' failed.
0|homebridge | [5/6/2019, 4:06:03 PM] [Cmd4] { Error: Command failed: python ~/.homebridge/Cmd4Scripts/front_door_state.py Get 'Front Door' 'StatusFault'
0|homebridge | at ChildProcess.exithandler (child_process.js:294:12)
0|homebridge | at ChildProcess.emit (events.js:189:13)
0|homebridge | at maybeClose (internal/child_process.js:970:16)
0|homebridge | at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
0|homebridge | killed: true,
0|homebridge | code: null,
0|homebridge | signal: 'SIGTERM',
0|homebridge | cmd:
0|homebridge | 'python ~/.homebridge/Cmd4Scripts/front_door_state.py Get \'Front Door\' \'StatusFault\'' }
0|homebridge | [5/6/2019, 4:06:03 PM] [Cmd4]
0|homebridge | [5/6/2019, 4:06:03 PM] [Cmd4]
I'm trying to use the thermostat accesory with data from a DHT22, what have to change into the code?
case "BatteruServoce":
should be:
case "BatteryService":
I'm struggling with intallation of State.js
Did someone get this working in Homebridge running in a docker container?
I would like to use this plugin for controlling different switches and Devices with the Shell...all Scripts i used previusly with the cmdswitch2 Plugin...this plugin is interesting because i can choose from a huge number of differend characterristics and Device Types...but how i can actually Control a real Device with this plugin? Like with the cmd_on and cmd_off Argument...?
I install another plugin ("homebridge-tuya-smartlamp") and boom, CMD4 starts throwing:
SyntaxError: Unexpected token A in JSON at position 0
at JSON.parse (<anonymous>)
at IncomingMessage.res.on (/usr/local/lib/node_modules/homebridge-cmd4/node_modules/github-version-checker/lib/check.js:64:21)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1129:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
homebridge.service: Main process exited, code=exited, status=255/EXCEPTION
homebridge.service: Failed with result 'exit-code'.
homebridge.service: Service RestartSec=3s expired, scheduling restart.
homebridge.service: Scheduled restart job, restart counter is at 2.
Nothing has changed in the CMD4 section of the config, it all validates via JSONlint and the problem continues to happen, even after both the Tuya plugin has been removed and CMD4 removed and reinstalled. If even one piece of CMD4 JSON exists in the config file, the error happens and takes down homebridge. every 10 seconds or so.
As I said, it's just like the plugin is now permanently broken—all (maybe) because of another plugin.
Hi contributors,
are there any plans to integrate the new HomeKit TV integration to homebridge-cmd4 in the next time?
Thanks to your great work in that.
Best regards.
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.