Trigger an update of a reading in a dummy variable.

Begonnen von andyclimb, 25 März 2016, 19:17:12

Vorheriges Thema - Nächstes Thema

andyclimb

I've got a dummy variable i use to set the value of an HTTPMOD device via a notify.  The HTTPMOD object process the response, and updates its readings.  the dummy variable uses
brightness { ReadingsVal( "testlamp","settings_brightness",0) }
To set its value... so the value of the dummy comes from the HTTPMOD.. this keeps everything in sync...  BUT...
it takes this value, BEFORE the HTTP response has come in from the HTTPMOD device.

is there a way to trigger an update to the dummyvar to get the correct value, or delay the update until the HTTPMOD has the response?

here is the device definitions..

define testlamp_brightness dummy
attr testlamp_brightness alias Brightness
attr testlamp_brightness group testlamp
attr testlamp_brightness room Light
attr testlamp_brightness setList brightness:slider,0,1,255
attr testlamp_brightness stateFormat brightness
attr testlamp_brightness userReadings brightness { ReadingsVal( "testlamp","settings_brightness",0) }
attr testlamp_brightness webCmd brightness
AM

MadMax-FHEM

Hi,

I read and re-read but I am not sure if I captured what is used to set what ;-)

Maybe setreading is a way to do want you want...
...directly sets a reading. ;-)


http://fhem.de/commandref_DE.html#setreading


Bye, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

andyclimb

Hi,

im not very good at explaining stuff, that is my fault. 

user sets a value of a dummy variable.  (there are a whole load of them in a group, used to control a lamp.. so color, brightness, mode, speed etc.)  these trigger a notify that is generic for every dummy for this device.. and send it to a HTTPMOD that then forwards it to the actual device.  This works great...

testlamp_.* set testlamp cmd $EVTPART0=$EVTPART1

so this notify picks up the value of the slider mentioned before and sends it to test lamp... the problem is that test lamp receives a json back with the new values... (to confirm that it has received it) and i can't get the dummy variable to process or change to that new value, or to trigger it to update to that value after a delay.  It always displays the last value that it was not the new one.  is there a way to get the stateFormat to display the value from an HTTPMOD reading but to update it when settings_brightness changes within HTTPMOD, or after a slight delay? 

I have tried setreading..  but it doesn't seem to work as i need.

testlamp_.* set testlamp cmd $EVTPART0=$EVTPART1 setreading $EVTPART0 $EVTPART1

gives me brightness:  and not brightness as a reading... not sure why that is... but the reading needs to be brightness...

Zitat
brightness  122 2016-03-25 20:13:37
brightness: 123 2016-03-25 20:13:37
AM

MadMax-FHEM

Hi,

I had just a quick (new) view.

Maybe it is clearer now.

But actually (of course) I'm "on the road" with no access to any fhem to try some things out...
...maybe I find some time this evening/tomorrow...

If possible: could you post the define (list) of the HTTPMOD and ond Dummy?!

By the way: happy easter!

Bye, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

andyclimb

sure... 

here is the HTTPMOD
Zitat
define testlamp HTTPMOD none 0
attr testlamp userattr get01ExtractAllJSON:0,1 get01Name getData getURL set01IMap set01Name set01ParseResponse:0,1 set01TextArg:0,1 set01URL
attr testlamp extractAllJSON 1
attr testlamp get01ExtractAllJSON 1
attr testlamp get01Name status
attr testlamp getURL http://192.168.1.200/data.esp?data=homepage
attr testlamp group testlamp
attr testlamp room Light
attr testlamp set01Name cmd
attr testlamp set01ParseResponse 1
attr testlamp set01TextArg 1
attr testlamp set01URL http://192.168.1.200/data.esp?$val
attr testlamp stateFormat settings_effect

here is the dummy
Zitat
define testlamp_brightness dummy
attr testlamp_brightness alias Brightness
attr testlamp_brightness group testlamp
attr testlamp_brightness room Light
attr testlamp_brightness setList brightness:slider,0,1,255
attr testlamp_brightness stateFormat brightness
attr testlamp_brightness userReadings brightness { ReadingsVal( "testlamp","settings_brightness",0) }
attr testlamp_brightness webCmd brightness

and the notify
Zitat
define testlamp_effect.notify notify testlamp_.* set testlamp cmd $EVTPART0=$EVTPART1

Thanks for the help. Happy Easter too!
AM

MadMax-FHEM

Hi,

just to start at some point (again) I re-read your first post.

There you mentioned that you can set what you want (or at least nearly) but instead of 'brightness' you get 'brightness:' and you don't know why.

I read through the wiki of notify (it's German only)


http://www.fhemwiki.de/wiki/Notify


and found the following:

Beispiel: Der Rückgabewert (wie im Beispiel) ist "currentPower: 6000". Jetzt steht im "$EVTPART0 == currentPower:" und im "$EVTPART1 == 6000" Das bedeutet, dass man sich nicht selbst den richtigen split (Perl Befehl) Aufruf ausdenken muss, dies übernimmt vielmehr Fhem.

So I think the $EVTPART0 is equal to 'brightness:' and so when you do a setreadings $EVTPART0 $EVTPART1 it is similar to 'setreadings brightness: 123'

Have you had a look in the event monitor?

There you see what is "in" the event...

To be sure that this is the reason you could call a print into Log and double check.

If that's the case/reason why you could call a sub that you put into myUtils and as parameter you give the $EVTPART0 and $EVTPART1 and just cut off the ':' and do a setreadings in that sub...


Is that the only problem?

So if you would get the reading like 'brightness 123' you're where you wanted to be or is there something else??

Bye, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

andyclimb

no that is correct, you are right.

i want the reading without the :

however, i might need a little delay on it, to allow the json to be returned and processed.

I've just thought about this more and it is not the best way to do it!  this is because the set by eventpart carries the value you are trying to set. not the return...

I've kind of solved it..  I use a notify on the reading that comes back form HTTPMOD!  then set the reading using that which works...  can't believe i didn't thing of that before.

What i want thought is a more generic form for it.  which i'll try and develop.
Might have another question later but for now its good.

Many thank for the help

Andrew
AM

MadMax-FHEM

FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

Benni

Zitat von: MadMax-FHEM am 27 März 2016, 22:25:13
I read through the wiki of notify (it's German only)


http://www.fhemwiki.de/wiki/Notify

...

By the way: there's a brief description for that in the English part of the official commandref:

http://fhem.de/commandref.html#notify