• 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
Generic device "generic_variable"
#1
It would be nice to have a generic device of the type "generic_variable". (Or is it already there and did I just didn't find it?)

The type would consist of "variable-name" and "variable-value".

In my current case I measure the light intensity and based on that value switches go on or off. Currently I use the device generic_dimmer. The external device sends a dimmer-value to pilight and within pilight I use the dimmer-value as a variable on which further logic depends.

The only disadvantage is now that this dimmer-level may only be 1 until 15. So I must translate the light intensity lux value to this values 1 until 15. (ok, not to difficult, but fuzzy in presentation. I am only interested in values between 0 and 1500 lux, so I  devide by 100, 15 meaning 1500 and above 

I would rather define the value in a generic_variable device as shown below.

In a matter of fact the code could just be identical to the generic_dimmer device with the value restriction removed.


Code:
{
 "devices": {
   "Light_intensity": {
     "protocol": [ "generic_variable" ],
     "id": [{
       "id": 100 ######### do users need an "id" or does pilight's internal logic need an id, then just pick one yourself
     }],
     "variable_value": 1500
   }
 },
 "gui": {
   "Light_intensity": {
     "name": "Light intensity in [lx]",
     "group": [ "Living" ],
     "media": [ "all" ]
   }
 }
}
 
Reply
#2
Why not using the generic_label. You can store any value in that?
 
Reply
#3
(04-30-2019, 08:06 PM)curlymo Wrote: Why not using the generic_label. You can store any value in that?

Thanks, I wondered why it would not be present already. I was thinking I could not use this label-value in a comparison. This will solve the issue.
 
Reply
#4
(05-01-2019, 01:22 PM)hansrijn2 Wrote:
(04-30-2019, 08:06 PM)curlymo Wrote: Why not using the generic_label. You can store any value in that?

Thanks, I wondered why it would not be present already. I was thinking I could not use this label-value in a comparison. This will solve the issue.
Just because I'm bit lazy: I have quite some "device-id" values that I need to keep track of to avoid doublets. Would it be an idea to allow the "id" to be omittted? (pilight could then pick one itselves). I do accept your priorities lie elsewhere ;-).
 
Reply
#5
How should pilight then recognize the correct device?
 
Reply
#6
(05-01-2019, 05:21 PM)curlymo Wrote: How should pilight then recognize the correct device?

I forgot to mention it would only be for generic devices. pilight would identify them by their name.
 
Reply
#7
Good point. That's something i will think about when rewriting the protocol into lua modules.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  New device which provides customizable buttons and start of own code OrTiN 5 2,142 02-13-2018, 08:16 PM
Last Post: Oliver
  Check status of device SeLi 11 4,044 01-07-2016, 07:57 PM
Last Post: pilino1234
  allow attribute "comment" for children of device, rule, gui Jan 2 1,360 12-19-2015, 11:31 PM
Last Post: woutput
  Generic weather koos147 4 3,140 04-26-2015, 07:46 AM
Last Post: Eekhoorn

Forum Jump:


Browsing: 1 Guest(s)