• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set dim level cli
#1
I have a really odd one at the moment where I am trying to control the dim level from command line

Commands attempted are

Code:
pilight-control -d houseTemp -s on -v dimlevel=10
[Dec 09 19:13:01:498449] pilight-control: ERROR: dht11: no gpio-platform configured

Code:
pilight-send -p generic_dimmer -i 198765 -d 22
[Dec 09 19:19:27:121006] pilight-send: ERROR: generic_dimmer: invalid dimlevel range


This works however, but I will always need a value high than 10
Code:
pilight-send -p generic_dimmer -i 198765 -d 10


A cut down version of my config is:

Code:
{
    "devices": {
        "temperature": {
            "protocol": [ "dht11" ],
            "id": [{
                "gpio": 5
            }],
            "humidity": 20.0,
            "temperature": 17.0,
            "poll-interval": 180
        },
        "houseTemp": {
            "protocol": [ "generic_dimmer" ],
            "id": [{
                "id": 198764
            }],
            "state": "off",
            "dimlevel": 19,
            "dimlevel-maximum": 30,
            "dimlevel-minimum": 15
        },
        "boiler_switch_on": {
            "protocol": [ "program" ],
            "id": [{
                "name": "boilder_switch"
            }],
            "stop-command": "wget -r --spider http://10.0.0.3/LED=ON &",
            "start-command": "wget -r --spider http://10.0.0.3/LED=ON &",
            "state": "stopped",
            "pid": 0,
            "program": "",
            "arguments": ""
        },
        "boiler_switch_off": {
            "protocol": [ "program" ],
            "id": [{
                "name": "boilder_switch_off"
            }],
            "stop-command": "wget -r --spider http://10.0.0.3/LED=OFF &",
            "start-command": "wget -r --spider http://10.0.0.3/LED=OFF &",
            "state": "stopped",
            "pid": 0,
            "program": "",
            "arguments": ""
        },
        "switch": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 100
            }],
            "state": "off"
        }
    },
    "rules": {
        "rule_boiler_on": {
            "rule": "IF switch.state IS on THEN switch DEVICE boiler_switch_on TO running",
            "active": 1
        },
        "rule_boiler_off": {
            "rule": "IF switch.state IS off THEN switch DEVICE boiler_switch_off TO running",
            "active": 1
        },
        "rule_boiler_temp_on": {
            "rule": "IF houseTemp.dimlevel > temperature.temperature AND houseTemp.state IS on THEN switch DEVICE switch TO on",
            "active": 1
        },
        "rule_boiler_temp_off": {
            "rule": "IF houseTemp.dimlevel <= temperature.temperature OR houseTemp.state IS off THEN switch DEVICE switch TO off",
            "active": 1
        }
    },
    "gui": {
            "temperature": {
            "name": "Study Temperature",
            "group": [ "House" ],
            "media": [ "all" ]
        },
        "switch": {
            "name": "Boiler Switch",
            "group": [ "House" ],
            "media": [ "all" ],
            "readonly": 1
        },
        "houseTemp": {
            "name": "Set Temperature",
            "group": [ "House" ],
            "media": [ "all" ]
        },
    },
    "settings": {
        "log-level": 6,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "webserver-enable": 1,
        "webserver-root": "/usr/local/share/pilight/webgui",
        "webserver-http-port": 5001,
        "webserver-cache": 1,
        "gpio-platform": "raspberrypi2"
    },
    "hardware": {
        "433gpio": {
            "sender": 4,
            "receiver": 1
        }
    },
    "registry": {
        "webserver": {
            "ssl": {
                "certificate": {
                    "secure": 0,
                    "location": "/etc/pilight/pilight.pem"
                }
            }
        },
        "pilight": {
            "version": {
                "current": "8.0.4"
            }
        }
    }


Does anyone have any suggestions on how I can get this to work?
 
Reply
#2
Your id you use in your config is different then the one from the cli?
 
Reply
#3
(12-10-2017, 04:58 PM)curlymo Wrote: Your id you use in your config is different then the one from the cli?

Hi Curlymo (First up thinks for developing such an amazing thing).

That was a typo in my post sorry, it is the same when I use the correct ID.

I have found an alternate way using your REST API which works perfectly if anyone else has the same issue.

thermostat.local:5001/control?device=houseTemp&state=on&values[dimlevel]=20
 
Reply
#4
That's wierd because the internals for the REST API are not different then from the CLI.
 
Reply
#5
(12-21-2017, 06:57 PM)curlymo Wrote: That's wierd because the internals for the REST API are not different then from the CLI.

That does seem weird, so I tried the following:


Code:
root@thermostat:/home/pi# pilight-send -p generic_dimmer -i 198764 -d 10
root@thermostat:/home/pi# pilight-send -p generic_dimmer -i 198764 -d 13
root@thermostat:/home/pi# pilight-send -p generic_dimmer -i 198764 -d 14
root@thermostat:/home/pi# pilight-send -p generic_dimmer -i 198764 -d 15
root@thermostat:/home/pi# pilight-send -p generic_dimmer -i 198764 -d 16
[Dec 22 07:48:22:544727] pilight-send: ERROR: generic_dimmer: invalid dimlevel range


So 15 seems to be the limit, which is the same as my  dimlevel-minimum, so I upped my min level and it still failed at 15 so seems unrelated.
 
Reply
#6
Bit more to add (and as a disclaimer I am certainly no C developer), however I think there is a bug in generic_dimmer.c

I increased the MAX_DIMMER_VALUE to 20 and recompiled, I was then able to set my dim level to 20 but no higher.

In the createCode function I also set:


Code:
if(json_find_number(code, "dimlevel-maximum", &itmp) == 0){
     max = (int)round(itmp);
     logprintf(LOG_ERR, "Found dimlevel-maxumum");
}
if(json_find_number(code, "dimlevel-minimum", &itmp) == 0){
     min = (int)round(itmp);
     logprintf(LOG_ERR, "Found dimlevel-minimum");
}

and neither IFs appear to be hit, so I think the issue is around this IF statement, so MAX and MIN are what are ever declared in the static variables.
 
Reply
#7
Can you check this fix:
https://github.com/pilight/pilight/commi...121161076f
 
Reply
#8
(12-29-2017, 11:10 PM)curlymo Wrote: Can you check this fix:
https://github.com/pilight/pilight/commi...121161076f

Installed the latest development version from github and it seems to be acting the same.
 
Reply
#9
What your theory?
 
Reply
#10
(01-06-2018, 04:26 PM)curlymo Wrote: What your theory?

Bit of digging and things have got more strange. I recompiled it again and it is picking up the min and max values. 
Code:
pilight-send -p generic_dimmer -i 198764 -d 25 -t
Is no longer failing with the message, however now it is not doing anything at all. The debug log is throwing out:
Code:
[Jan 06 17:52:12:878842] pilight-daemon: DEBUG: broadcasted: {"origin":"sender","protocol":"generic_dimmer","message":{"id":198764,"dimlevel":25,"state":"on"},"repeat":1,"uuid":"0000-b8-27-eb-3a1d76"}
So it is attempting to send it but the end result isn't taking effect, with one exception, if I send:
Code:
pilight-send -p generic_dimmer -i 198764 -d 15 -t
(or bellow 15) it drops the value to 15

I hope to have time to dig into it more tomorrow, not sure if you have any ideas.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [8.1.4] log-level 6 but no detailed information robbie 4 315 03-31-2019, 05:26 PM
Last Post: curlymo
  Recommended Dimmer module with level setting alasdairc 3 1,467 10-14-2015, 08:40 PM
Last Post: alasdairc

Forum Jump:


Browsing: 1 Guest(s)