luisiam / homebridge-cmdswitch2

CMD Plugin for HomeBridge (API 2.0): https://github.com/nfarina/homebridge
Apache License 2.0
176 stars 29 forks source link

[CMD Switch] Failed to determine Lamp1 state. ; /bin/sh: 1: undefined: not found #9

Closed TonyPeperoni closed 7 years ago

TonyPeperoni commented 7 years ago

I am not sure if this is the place to post this issue (and perhaps it is just my inexperience), but the cmdswitch2 plugin seems to hit an error in my implementation. I have installed homebridge and the plugin globally with sudo and my config.json is located in ~/.homebridge (raspbian Jessy). Running " tail -f /var/log/homebridge.log" I am getting: [2017-01-02 21:19:50] Loaded plugin: homebridge-cmdswitch2 [2017-01-02 21:19:50] Registering platform 'homebridge-cmdswitch2.cmdSwitch2' [2017-01-02 21:19:50] --- which is good but then the second phase fails [CMD Switch] Initializing platform accessory 'Lamp1'... [CMD Switch] Failed to determine Lamp1 state. [CMD Switch] /bin/sh: 1: undefined: not found

Here is a snippet from my config.json (i have two platforms defined):

"platforms": [
            {
            "platform": "Nest",
            "token" : "****************************"
            "clientId": "*****************",
            "clientSecret": "****************",
            "code": "******",
            "username" : "ton@*********",
            "password" : "***************"
            },
            {
            "platform":"cmdSwitch2",
            "name": "CMD Switch",
            "switches":[
                    {
                    "name": "Lamp1",
                    "on_cmd": "/var/www/rfoutlet/codesend 13857643",
                    "off_cmd": "/var/www/rfoutlet/codesend 13857642"
                     }
                 ]
            }
            ]

}

Apologies in Advance ;-) Tony

p.s. In the IOS Home App the accessoire Lamp1 says "not responding". And in the IOS home app the lamp can't be turned on /off by pressing. But using Siri voice command you can turn it on/off).

Adding some findings: Adding a bogus state_cmd solves the state in the IOS home app and the lamp can now be turned on /off by pressing.
My trick was: "state_cmd": "/var/www/rfoutlet/codesend 13857642 | grep -i 'bogus'" I can now see that at Homebridge startup the [CMD Switch] Initializing platform accessory goes well and [CMD Switch] reports Lamp1 (in a valid state) as off (obviously with an RF Lamp this is bogus and just a trick). This proofs that there is a software dependancy towards "state_cmd" in order to turn on / off the lamp by pressing in the IOS home app

luisiam commented 7 years ago

That's strange for me. I am running raspbian as well. Even if state_cmd is undefined, it won't throw an error. What version of node are you using? Try to set state_cmd to an empty string "" and see if it fixes the problem.

TonyPeperoni commented 7 years ago

Hi Luis, this I already had investigated and indeed setting state_cmd to an empty string "" fixes the problem. I am using the Pi 3. Not sure what data you need but ... cat /etc/os-release gives: PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)"

cat /etc/rpi-issue gives Raspberry Pi reference 2015-11-21 Generated using Pi-gen, https://github.com/RPi-Distro/Pi-gen, jessie-stage4

cat /etc/debian_version 8.0

Need something else?

luisiam commented 7 years ago

What do you get if you run node -v?

TonyPeperoni commented 7 years ago

running node -v gives v4.0.0

luisiam commented 7 years ago

That's probably why. I am running the latest node v7.4.0.

I have implemented some countermeasures. Try to update with npm install -g git+https://github.com/luisiam/homebridge-cmdswitch2.git#1e10a252b3800dffac50ee16c425cc6e72989d2b and remove your empty string setting.

TonyPeperoni commented 7 years ago

okay will do & thanks for responding

best regards, Tony

TonyPeperoni commented 7 years ago

I took me a while to test but indeed upgrading to the latest node v7.4.0 resolved this behaviour ;-) Thanks & regards, Tony