espeasy with relay and normai switch how toggle?

Begonnen von kroonen, 30 Dezember 2015, 19:00:13

Vorheriges Thema - Nächstes Thema

kroonen

Hi,

I have aan esp8266 with espeasy loaded.

Now I can switch he really with traditional switch and within the fhem interface. Now I have a switch on the gpis pins and I can switch it with mqtt

The problem is that if I use the web interface the esp doen't go to to the other state. Any Idea how that I can solve this, something to make it toggle? I have this in my fhem config

define Buitenverlichting dummy
attr Buitenverlichting devStateIcon on:FS20.on off:FS20.off
attr Buitenverlichting eventMap on:on off:off
attr Buitenverlichting group Lampen
attr Buitenverlichting icon light_outdoor
attr Buitenverlichting room Buiten

define relayswitchaan2 notify Buitenverlichting:off { GetHttpFile('192.168.180.90:80', '/control?cmd=GPIO,2,0');; }
attr relayswitchaan2 room Buiten

define relayswitchaan2 notify Buitenverlichting:on { GetHttpFile('192.168.180.90:80', '/control?cmd=GPIO,2,1');; }
attr relayswitchaan2 room Buiten

define schakelaar MQTT_DEVICE
attr schakelaar IODev mqtt
attr schakelaar autoSubscribeReadings /hooks/devices/4/SensorData/+
attr schakelaar eventMap /1.00:on /0.00:off
attr schakelaar room Buiten
#attr schakelaar stateFormat $EVENT
attr schakelaar subscribeReading_status /hooks/devices/4/SensorData/Switch

define Schakelaar_on notify schakelaar:status.* set Buitenverlichting $EVTPART1



kroonen

Hi

Found the solution

define Schakalaar_1 notify schakelaar:status.* {if (Value("Buitenverlichting") eq "on") {fhem ("set Buitenverlichting off")}else {fhem ("set Buitenverlichting on")};;;;}

The the switch works with toggle