dummy variables in notify device

Begonnen von fatman, 23 Januar 2017, 22:46:26

Vorheriges Thema - Nächstes Thema

fatman

Hi,
it will be extremely useful if the Notify device will be able to has dummy variables (readingList/setList etc as used in Dummy device). The Notify device is sort of stateless without that (it can do side-effects but has no its own readings).
Thanks a lot
HB

Example:
I have two outside thermometers (say west and east), since I have no place without sunshine to put single thermometer.
So, the correct outside temperature is a minimum of measured values  (the higher measurement is incorrect since the sunshine). 
Thus, I need a "virtual"  fhem device, having a reading computed as a minimum of two given devices (physical thermometers), updated every time the physical device are updated. Which can be easily implemented as Notify device, up to the problem of missing readingList.

By the way, minimum function is also a missing FHEM feature.

DeeSPe

With a notify you can simply use "setreading".

Let's assume you got 2 temperature sensors (T1 and T2) and you also want the temperature as a reading from T2 inside of T1.
Then you can use a notify like this:
define n_T2toT1 notify T2:temperature.* setreading T1 temperature2 $EVTPART1

Now you got a reading temperature2 inside of T1 with the temperature value of T2.

Cheers.
Dan
MAINTAINER: 22_HOMEMODE, 98_Hyperion, 98_FileLogConvert, 98_serviced

Als kleine Unterstützung für meine Programmierungen könnt ihr mir gerne einen Kaffee spendieren: https://buymeacoff.ee/DeeSPe

KölnSolar

By the way,
Zitat
minimum function is also a missing FHEM feature.
min is implemented in statistics module, in plots.....
Why do you think the function is missing ? What is your case ? min per reading, per hour/day/month/year ? min of several readings of 1 device or readings of several devices ? In general or for specific device type ?
Regards Markus
RPi3/2 buster/stretch-SamsungAV_E/N-RFXTRX-IT-RSL-NC5462-Oregon-CUL433-GT-TMBBQ-01e-CUL868-FS20-EMGZ-1W(GPIO)-DS18B20-CO2-USBRS232-USBRS422-Betty_Boop-EchoDot-OBIS(Easymeter-Q3/EMH-KW8)-PCA301(S'duino)-Deebot(mqtt2)-zigbee2mqtt

fatman

DeeSPe,
thanks for the
define n_T2toT1 notify T2:temperature.* setreading T1 temperature2 $EVTPART1
hint.
I missed that I can use setreading on any device including notify without readingList declaration.
It works fine, I use it in a little bit different way (copy of both readings will be stored in notify itself).

DeeSPe

Zitat von: fatman am 24 Januar 2017, 20:37:00
DeeSPe,
thanks for the
define n_T2toT1 notify T2:temperature.* setreading T1 temperature2 $EVTPART1
hint.
I missed that I can use setreading on any device including notify without readingList declaration.
It works fine, I use it in a little bit different way (copy of both readings will be stored in notify itself).

Great if it's working for you! ;)
Sure, you can use it in your own manner...

Cheers
Dan
MAINTAINER: 22_HOMEMODE, 98_Hyperion, 98_FileLogConvert, 98_serviced

Als kleine Unterstützung für meine Programmierungen könnt ihr mir gerne einen Kaffee spendieren: https://buymeacoff.ee/DeeSPe

fatman

Markus,
I am not looking for a minima of a time sequence of values of single device readings, but for a minimum of two current values of two independet readings (read by different devices). I am not a Perl specialist so I am using tricky
no warnings 'redefine';;
sub my_min ($$) { $_[$_[0] > $_[1]] }

since
use List::Util qw[min max];;
somehow do not work for me.

KölnSolar

#6
If I understood your case right, userReadings should be helpful. depends a little bit on the detailed case.
Assuming device1 and device2  deliver a reading temperature you might add a userReading mintemp which ist the lower temperature of both measurements
attr device1 userReadings mintemp:temperature.* {my $temp1 = ReadingsVal($name,"temperature",0);; my $temp2 = ReadingsVal("device2","temperature",0);; if ($temp1 > $temp2) {$temp2} else {$temp1} }
RPi3/2 buster/stretch-SamsungAV_E/N-RFXTRX-IT-RSL-NC5462-Oregon-CUL433-GT-TMBBQ-01e-CUL868-FS20-EMGZ-1W(GPIO)-DS18B20-CO2-USBRS232-USBRS422-Betty_Boop-EchoDot-OBIS(Easymeter-Q3/EMH-KW8)-PCA301(S'duino)-Deebot(mqtt2)-zigbee2mqtt

fatman

#7
Lets go back to my original desire for dummy setLits/readingList feature for notify device. Even with setreading running well, there is still one good reason for having such feature:
The possibility to be set by set command or by hand in web interface. This is not possible without setLits feature.

Double-sensored temperature was just a simple example. As far as I know, there are at least  two situations where setreading trick cannot be used (without additional dummy devices):

  • notify device in question is dependent on some user-defined parameters (and we want to change them on the fly by clicking set button on the web interface)
  • notify device in question is driven by PID20 device (which is implemented in such a way that its resulting value is stored not by setreading but by set to the prescribed device)

I deeply believe that auxiliary additional  dummy devices are usable but dangerously confusing and probably it is not too hard to combine notify and dummy code (unfortunately, too hard for me). Thanks a lot!

DeeSPe

With a dummy device you can do what ever you want, that's its purpose. ;)
But you have to implement the logic by yourself by using notify and/or DOIF.
It's not that hard, I swear... :P
Look into the commandref for notify and DOIF and into the forum, there's a solution for almost anything.
If no solution is available, don't hesitate to ask. We'll make it possible if needed.

Cheers
Dan
MAINTAINER: 22_HOMEMODE, 98_Hyperion, 98_FileLogConvert, 98_serviced

Als kleine Unterstützung für meine Programmierungen könnt ihr mir gerne einen Kaffee spendieren: https://buymeacoff.ee/DeeSPe

fatman

Zitat von: DeeSPe am 25 Januar 2017, 22:04:36
With a dummy device you can do what ever you want, that's its purpose. ;)
But you have to implement the logic by yourself by using notify and/or DOIF.
It's not that hard, I swear... :P
Look into the commandref for notify and DOIF and into the forum, there's a solution for almost anything.
If no solution is available, don't hesitate to ask. We'll make it possible if needed.

Cheers
Dan
Yes, I know about notify. My point is that notify is missing setList feature well implemented in dummy device.

DeeSPe

Zitat von: fatman am 25 Januar 2017, 22:12:13
Yes, I know about notify. My point is that notify is missing setList feature well implemented in dummy device.

I just try to explain that this is not its (notify) purpose. ???
A dummy device is the base of any custom device.
There you have the attributes to configure it properly, from frontend perspective.
With the code in notify/DOIF you create your logic for the different (frontend) set(s) you created for the dummy device.
So, it's all up to you to try yourself using the tools FHEM is giving you. :)

Cheers
Dan
MAINTAINER: 22_HOMEMODE, 98_Hyperion, 98_FileLogConvert, 98_serviced

Als kleine Unterstützung für meine Programmierungen könnt ihr mir gerne einen Kaffee spendieren: https://buymeacoff.ee/DeeSPe

fatman

Dan,
I tried to combine dummy and notify on my own in the hope I will get the device I need, but I have not perfectly succeeded, and, which is the worst, I have to merge my modification with every update of FHEM. This is boring and potentially dangerous at least to my marriage, since FHEM drives heating of our house ;)
So, I tried this forum...
I believe that setList functionality perfectly suits to notify as a general purpose device (as well as dummy) - except the missing possibility of setting its "states" from the user. Think a minute: Notify and dummy are two general-purpose devices, and I am looking for a generalization (or unification, if you like) of them to a new, more general device, which can obtain events and has an user interface.
Attributes  unfortunately are not the solution, I know that attribute values be set in web interface (in a text field), but not in too elegant way, no widgets, sliders, buttons, pull-up menus etc. are supported). Attributes are rather "technical" parameters of the system than user-defined values.
Sorry for disturbing,
HB

DeeSPe

Zitat von: fatman am 26 Januar 2017, 21:59:09
Dan,
I tried to combine dummy and notify on my own in the hope I will get the device I need, but I have not perfectly succeeded, and, which is the worst, I have to merge my modification with every update of FHEM. This is boring and potentially dangerous at least to my marriage, since FHEM drives heating of our house ;)
So, I tried this forum...
I believe that setList functionality perfectly suits to notify as a general purpose device (as well as dummy) - except the missing possibility of setting its "states" from the user. Think a minute: Notify and dummy are two general-purpose devices, and I am looking for a generalization (or unification, if you like) of them to a new, more general device, which can obtain events and has an user interface.
Attributes  unfortunately are not the solution, I know that attribute values be set in web interface (in a text field), but not in too elegant way, no widgets, sliders, buttons, pull-up menus etc. are supported). Attributes are rather "technical" parameters of the system than user-defined values.
Sorry for disturbing,
HB

You can assign widget how ever you want! It's just a matter of the definition!
In setList of the dummy you could set:
dim:slider,10,0.5,30
Then in webCmd just set:
dim

Now you got a nice slider to set the temperature of a heater!
There are a lot more widgets to use! Watch out for the keyword "widgetOverride".

Cheers
Dan
MAINTAINER: 22_HOMEMODE, 98_Hyperion, 98_FileLogConvert, 98_serviced

Als kleine Unterstützung für meine Programmierungen könnt ihr mir gerne einen Kaffee spendieren: https://buymeacoff.ee/DeeSPe

fatman

#13
Zitat von: DeeSPe am 26 Januar 2017, 22:09:26
You can assign widget how ever you want! It's just a matter of the definition!
In setList of the dummy you could set:
dim:slider,10,0.5,30
Then in webCmd just set:
dim

Now you got a nice slider to set the temperature of a heater!
There are a lot more widgets to use! Watch out for the keyword "widgetOverride".
Yes! Exactly! I know ;) and now, I like to have the same ability (including stateFormat) for notify device ;)