Page 3 of 4

Re: Dashticz - [BETA] - Function - Do something at a specific value

Posted: Saturday 27 May 2017 11:14
by jake
htilburgs wrote: Thnx... And updated the wiki too....
I would like to propose a litte change in the Wiki regarding the change of color, based on value xyz:

- Start with the paragraph about finding the right variable for monitoring, so before explaining what to add to custom.js (common practice for manuals, since people try to follow the manual line by line and won't recognize the next paragraph while they get stuck in the paragraph before)
- Don't use the example json command for all devices, but start with the one for the specific device, since that is what the user is after in the first place:

Code: Select all

/json.htm?type=devices&rid=IDX
and point for all other json command to the Domoticz wiki: http://www.domoticz.com/wiki/Domoticz_A ... rtain_type

Re: Dashticz - [BETA] - Function - Do something at a specific value

Posted: Saturday 27 May 2017 15:30
by mvveelen
htilburgs wrote:
I also noticed a minor in .trashcan. After height the : is missing. (I know, I'm a nitpicker ;-))
Hahaha, added the : after height :D

Re: Dashticz - [BETA] - Function - Do something at a specific value

Posted: Saturday 27 May 2017 21:19
by htilburgs
jake wrote:
htilburgs wrote: Thnx... And updated the wiki too....
I would like to propose a litte change in the Wiki regarding the change of color, based on value xyz:

- Start with the paragraph about finding the right variable for monitoring, so before explaining what to add to custom.js (common practice for manuals, since people try to follow the manual line by line and won't recognize the next paragraph while they get stuck in the paragraph before)
- Don't use the example json command for all devices, but start with the one for the specific device, since that is what the user is after in the first place:

Code: Select all

/json.htm?type=devices&rid=IDX
and point for all other json command to the Domoticz wiki: http://www.domoticz.com/wiki/Domoticz_A ... rtain_type
I understand what you mean. Take a look at it tomorow...

Re: Dashticz - [BETA] - Function - Do something at a specific value

Posted: Tuesday 30 May 2017 13:28
by htilburgs
jake wrote:
htilburgs wrote: Thnx... And updated the wiki too....
I would like to propose a litte change in the Wiki regarding the change of color, based on value xyz:

- Start with the paragraph about finding the right variable for monitoring, so before explaining what to add to custom.js (common practice for manuals, since people try to follow the manual line by line and won't recognize the next paragraph while they get stuck in the paragraph before)
- Don't use the example json command for all devices, but start with the one for the specific device, since that is what the user is after in the first place:

Code: Select all

/json.htm?type=devices&rid=IDX
and point for all other json command to the Domoticz wiki: http://www.domoticz.com/wiki/Domoticz_A ... rtain_type
Finaly found some time and changed the Wiki. Thanks for your possitive reply.
Btw, when you've an account, you can edit the wiki yourself....;-)

Re: Dashticz - Function - Trigger action on specific value

Posted: Thursday 08 June 2017 21:45
by EdwinK
Why wouldn't this work?

Code: Select all

// temp

function getStatus_176(idx,value,device){
   if(parseFloat(device['Data'])>20){
      $('div.block_176').removeClass('warning').addClass('warningorange');
   }
   else if(parseFloat(device['Data'])>23){
      $('div.block_176').removeClass('warningorange').addClass('warning');
   }
   else {
      $('div.block_176').removeClass('warning').removeClass('warningorange');
   }
}


Re: Dashticz - Function - Trigger action on specific value

Posted: Thursday 08 June 2017 21:52
by mvveelen
EdKo66 wrote:Why wouldn't this work?

Code: Select all

// temp

function getStatus_176(idx,value,device){
   if(parseFloat(device['Data'])>20){
      $('div.block_176').removeClass('warning').addClass('warningorange');
   }
   else if(parseFloat(device['Data'])>23){
      $('div.block_176').removeClass('warningorange').addClass('warning');
   }
   else {
      $('div.block_176').removeClass('warning').removeClass('warningorange');
   }
}

Change Data to Temp :)

Re: Dashticz - Function - Trigger action on specific value

Posted: Thursday 08 June 2017 23:04
by EdwinK
mvveelen wrote:
EdKo66 wrote:Why wouldn't this work?

Change Data to Temp :)
Of course... Thanks ;)

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 12:26
by gielie
I have tried this one, but it doesnt work, can someone tell me why and give me a solution.

Code: Select all


// temp

function getStatus_304(idx,value,device){
   if(parseFloat(device['Temp'])>20){
      $('div.block_304').removeClass('warningred').removeClass('warningorange').addClass('warning');
   }
   else if(parseFloat(device['Temp'])>22){
      $('div.block_304').removeClass('warning').removeClass('warningred').addClass('warningorange');
   } 
   else if(parseFloat(device['Temp'])>24){
      $('div.block_304').removeClass('warningorange').removeClass('warning').addClass('warningred');
   }
   else {
      $('div.block_304').removeClass('warning').removeClass('warningorange').removeClass('warningred');
   }
}


Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 12:44
by htilburgs
gielie wrote:I have tried this one, but it doesnt work, can someone tell me why and give me a solution.

Code: Select all


// temp

function getStatus_304(idx,value,device){
   if(parseFloat(device['Temp'])>20){
      $('div.block_304').removeClass('warningred').removeClass('warningorange').addClass('warning');
   }
   else if(parseFloat(device['Temp'])>22){
      $('div.block_304').removeClass('warning').removeClass('warningred').addClass('warningorange');
   } 
   else if(parseFloat(device['Temp'])>24){
      $('div.block_304').removeClass('warningorange').removeClass('warning').addClass('warningred');
   }
   else {
      $('div.block_304').removeClass('warning').removeClass('warningorange').removeClass('warningred');
   }
}

I think there are two errors:
- the device['Temp'] and should be device['Data']
- Start with the highest and work down to the lowest temperature

Code: Select all

function getStatus_304(idx,value,device){
   if(parseFloat(device['Data'])>24){
      $('div.block_304').removeClass('warning').removeClass('warningorange').addClass('warningred');
   }
   else if(parseFloat(device['Data'])>22){
      $('div.block_304').removeClass('warning').removeClass('warningred').addClass('warningorange');
   } 
   else if(parseFloat(device['Data'])>20){
      $('div.block_304').removeClass('warningorange').removeClass('warningred').addClass('warning');
   }
   else {
      $('div.block_304').removeClass('warning').removeClass('warningorange').removeClass('warningred');
   }
}

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 12:51
by EdwinK
Don't know why it wouldn't work for you. You did put it in custom.js?
I have the problem because it is a sensor with a '_1' in it.

Mmm. Yesterday I was told to change it from 'Data' to 'Temp'.
Even rain isn't flashing anymore :(

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 13:02
by htilburgs
EdKo66 wrote:Don't know why it wouldn't work for you. You did put it in custom.js?
I have the problem because it is a sensor with a '_1' in it.

Mmm. Yesterday I was told to change it from 'Data' to 'Temp'.
That can be, but it's not right...;-)
When you check your device with http://domoticz_url:port/json.htm?type=devices&rid=304, you wil see there is no parameter Temp. What you find is Data. So it should be Data. :idea:

Furthermore, you started with the lowest values. In that case the formule won't work. Work down from high to low.
Example in you're case when it is 22,5 degree the warningorange AND warningred are true. Which one should be picked?? :?:

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 13:13
by EdwinK
htilburgs wrote:
EdKo66 wrote:Don't know why it wouldn't work for you. You did put it in custom.js?
I have the problem because it is a sensor with a '_1' in it.

Mmm. Yesterday I was told to change it from 'Data' to 'Temp'.
That can be, but it's not right...;-)
When you check your device with http://domoticz_url:port/json.htm?type=devices&rid=304, you wil see there is no parameter Temp. What you find is Data. So it should be Data.
but... there is a Temp parameter. Are so I think.

Code: Select all

"result" : [
      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 100,
         "CustomImage" : 0,
         "Data" : "18.1 C, 0 %",
         "Description" : "",
         "DewPoint" : "18.10",
         "Favorite" : 1,
         "HardwareID" : 13,
         "HardwareName" : "RFXcom",
         "HardwareType" : "RFXCOM - RFXtrx433 USB 433.92MHz Transceiver",
         "HardwareTypeVal" : 1,
         "HaveTimeout" : false,
         "Humidity" : 0,
         "HumidityStatus" : "Dry",
         "ID" : "1001",
         "LastUpdate" : "2017-06-09 13:10:33",
         "Name" : "Buiten temp",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : 6,
         "SubType" : "Rubicson/IW008T/TX95",
[b]         "Temp" : 18.100000000000001,
[/b]        

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 13:18
by htilburgs
Ok, that differs from mine. Use this code in config.js and it should work.

Code: Select all

function getStatus_304(idx,value,device){
   if(parseFloat(device['Temp'])>24){
      $('div.block_304').removeClass('warning').removeClass('warningorange').addClass('warningred');
   }
   else if(parseFloat(device['Temp'])>22){
      $('div.block_304').removeClass('warning').removeClass('warningred').addClass('warningorange');
   } 
   else if(parseFloat(device['Temp])>20){
      $('div.block_304').removeClass('warningorange').removeClass('warningred').addClass('warning');
   }
   else {
      $('div.block_304').removeClass('warning').removeClass('warningorange').removeClass('warningred');
   }
}

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 13:36
by EdwinK
Put this in, but for now it will not be working because of the multi-sensor thing even if the humidity doesn't really work

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 13:42
by EdwinK
htilburgs wrote:Ok, that differs from mine. Use this code in config.js and it should work.
Shouldn't it be in custom.js?

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 14:00
by htilburgs
Sorry, it should be config.js. My mistake...

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 14:05
by EdwinK
*flashing buttoons*
*flashing buttoons*
Screen Shot 2017-06-09 at 14.03.31.png (108.15 KiB) Viewed 3312 times
Yes... It works. Had fixed a little typo (You forgot the closing ' ).

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 14:13
by htilburgs
Ok, happy and sorry.... Probably a Cut & Paste error.
Nice to hear it works!!

Re: Dashticz - Function - Trigger action on specific value

Posted: Friday 09 June 2017 14:20
by gielie
Yes the code works, tanks. And like Ed told, the last Temp misses a '

Re: Dashticz - Function - Trigger action on specific value

Posted: Sunday 25 June 2017 22:13
by lukev
Any method to extract temp from tem/hum sensor?
My data reads this:

Code: Select all

Data	"27.8 C, 47 %"
so the tigger doesn't work...