Initialisation of variables

Begonnen von homer, 24 November 2013, 21:02:03

Vorheriges Thema - Nächstes Thema

homer

Hi All,

When FHEM starts it seems like all variables are undefined. For example, I have a loungelight defined as follows:

define LOUNGELIGHT TRX_LIGHT LIGHTWAVERF F1028702 lounge
attr LOUNGELIGHT icon FS20.on
attr LOUNGELIGHT room Lighting

define a12 at *06:00 {fhem "set LOUNGELIGHT on" if (Value("myTwilight") < 5)}
define a14 at *{ReadingsVal("myTwilight","sr_indoor","00:00:10")} set LOUNGELIGHT off

and when I first look at it's status, it is reported as ??? until I switch it myself or it is switched by an event. Is it possible to initialise a device to a known state? Also, can the same be done for dummy variables?

Thanks
Homer

fiedel

Hi Mr. Simpson  ;)

I do it this way:



define Func_Start_Init_W watchdog . 00:00:01 SAME { \
\
fhem("set CUNO_LAN raw B00");;\
fhem("set Dum_Radio_con_D off");;\
fhem("set Dum_Kl_Sperr_D off");;\
fhem("set Dum_SM_D Systemstart");;\
}



This code will be executed at every system start. My variables shown here, are all dummies. But you are free to put every code of your coice in this function. Just make sure that this function appears in the CFG below the definitions of the used variables or devices.

Best regards

Frank
FeatureLevel: 6.1 auf Wyse N03D ; Deb. 11 ; Perl: v5.14.2 ; IO: HM-MOD-RPI-PCB + VCCU|CUL 868 V 1.66|LinkUSBi |TEK603
HM: SEC-SCO|SCI-3-FM|LC-SW4-PCB|ES-PMSW1-PL|RC-4-2|SEN-MDIR-O|SEC-WDS-2
CUL: HMS100TF|FS20 S4A-2 ; OWDevice: DS18S20|DS2401|DS2406|DS2423

rudolfkoenig

FHEM saves the state of all devices in the fhem.state file at shutdown, and it evaluates this file after digesting the fhem.cfg at startup.
If this does not work for you, you can set the values in a notify triggered by the global:INITIALIZED event.

homer

Great. Thanks both for your help. I'll give these suggestions a try.