Icon ist falsch. War: devStateIcon hat umgekehrte Logik

Begonnen von fhemer, 16 Mai 2016, 14:47:27

Vorheriges Thema - Nächstes Thema

fhemer

Hallo,

bin jetzt schon echt weit und meine Zeitschaltuhren mit Zufallswert funktionieren auch! :-)
Nur beim devStateIcon bin ich etwas zu doof. Es ist immer falschherum. Also die Birne ist dunkel, wenn der Ausgang high ist und umgekehrt. Die on und off Befehle funktionieren korrekt. Hier mal mein aktueller Code (habe schon mehrere Varianten bei devStateIcon probiert):

setdefaultattr valueFn {($VALUE eq "on")?"off":"on"} #gilt für alle?!?

define i2c20pA2 readingsProxy i2c20:PortA2
attr i2c20pA2 room ops
attr i2c20pA2 devStateIcon off:off:on on:on:off  #war auch schon on:on:off off:off:on
attr i2c20pA2 alias AZ Rolladen 2 runter
attr i2c20pA2 setList on off
attr i2c20pA2 setFn {($CMD eq "on")?"PortA2 on":"PortA2 off"}
attr i2c20pA2 webCmd on:off:on-for-timer 10

(danach kommt die Zeitschaltuhr, die ja funktioniert (mit dem Symbol in falscher Logik!))

Danke schonmal

VG
fhemer


viegener

Du hast doch eine valueFn angegeben, die den Wert invertiert, unabhängig, dass ich das extrem verwirrend finde sorgt doch genau diese dafür das alles verdreht ist. Mit anderen Worten PortA2 ist on, dann ist in i2c20 das Reading auf on und in i2c20pA2 der state auf off  :o

Mich würde das in den Wahnsinn treiben  ::)
Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

fhemer

#2
Hallo viegener,

Danke für die Antwort. Hast recht, war wohl ein Übrigbleibsel und ich habs entfernt und entsprechend angepasst.
Jetzt geht auch alles, außer das Icon für A1. Das bleibt auf "an", in der Realität ist aber alles OK und die Lampe ist physikalisch aus! So wie es sein soll. Das Problem ist nur beim Icon für A1, bei A2 ist alles in Ordnung. Hintergrund: B0 und A0 steuern einen Rollladenmotor (hoch/runter), A1 und A2 einen anderen. Die Ausgänge sollen sich gegenseitig softwaremäßig verriegeln. Das funktioniert wie gesagt in der Realität, das Icon bei A1 bleibt aber an!

Hier mal der Code:

attr global logfile ./log/fhem-%Y-%m.log
attr global modpath .
attr global statefile ./log/fhem.save
attr global verbose 3
attr global updateInBackground
attr global latitude 50.111
attr global longitude 8.682

define telnetPort telnet 7072 global

define WEB FHEMWEB 8083 global

define WEBphone FHEMWEB 8084 global
attr WEBphone stylesheetPrefix smallscreen

define WEBtablet FHEMWEB 8085 global
attr WEBtablet stylesheetPrefix touchpad

# Fake FileLog entry, to access the fhem log from FHEMWEB
define Logfile FileLog ./log/fhem-%Y-%m.log fakelog

define autocreate autocreate
attr autocreate filelog ./log/%NAME-%Y.log

define eventTypes eventTypes ./log/eventTypes.txt

# Disable this to avoid looking for new USB devices on startup
define initialUsbCheck notify global:INITIALIZED usb create

define i2c RPII2C 1
attr i2c alias Onboard I2C Controller 1
attr i2c room ops

define i2c20 I2C_MCP23017 0x20
attr i2c20 IODev i2c
attr i2c20 room ops
attr i2c20 OutputPorts A0,A1,A2,A3,A4,A5,A6,A7,B0,B1,B2,B3,B4,B5,B6,B7
set i2c20 PortB0 off # ausschalten
set i2c20 PortA0 off # ausschalten
set i2c20 PortA1 off
set i2c20 PortA2 off

define i2c20pB0 readingsProxy i2c20:PortB0
attr i2c20pB0 room ops
attr i2c20pB0 devStateIcon on:on:off off:off:on
attr i2c20pB0 alias AZ Rolladen 1 hoch
attr i2c20pB0 setList on off
attr i2c20pB0 setFn {($CMD eq "on")?"PortB0 on":"PortB0 off"}
attr i2c20pB0 webCmd on:off:on-for-timer 10

define i2c20pA0 readingsProxy i2c20:PortA0
attr i2c20pA0 room ops
attr i2c20pA0 devStateIcon on:on:off off:off:on
attr i2c20pA0 alias AZ Rolladen 1 runter
attr i2c20pA0 setList on off
attr i2c20pA0 setFn {($CMD eq "on")?"PortA0 on":"PortA0 off"}
attr i2c20pA0 webCmd on:off:on-for-timer 10

define i2c20pA1 readingsProxy i2c20:PortA1
attr i2c20pA1 room ops
attr i2c20pA1 devStateIcon on:on:off off:off:on
attr i2c20pA1 alias AZ Rolladen 2 hoch
attr i2c20pA1 setList on off
attr i2c20pA1 setFn {($CMD eq "on")?"PortA1 on":"PortA1 off"}
attr i2c20pA1 webCmd on:off:on-for-timer 10

define i2c20pA2 readingsProxy i2c20:PortA2
attr i2c20pA2 room ops
attr i2c20pA2 devStateIcon on:on:off off:off:on
attr i2c20pA2 alias AZ Rolladen 2 runter
attr i2c20pA2 setList on off
attr i2c20pA2 setFn {($CMD eq "on")?"PortA2 on":"PortA2 off"}
attr i2c20pA2 webCmd on:off:on-for-timer 10

# Rollladenmotorschutz

define RollladenschutzA0 notify i2c20pB0:on set i2c20pA0 off
define RollladenschutzB0 notify i2c20pA0:on set i2c20pB0 off
define RollladenschutzA2 notify i2c20pA1:on set i2c20pA2 off
define RollladenschutzA1 notify i2c20pA2:on set i2c20pA1 off




viegener

Beim drüberschauen konnte ich jetzt auch nicht sehen, warum sich A1 anders verhalten sollte, ich denke Du musst da nochmal genau die Unterschiede zwischen den Roladenschaltpaaren anschauen.

Allerdings möchte ich Bedenken anmelden, ob Deine Motorschutz-Notifys so wirklich funktionieren. Wenn eine Fehlschaltung auftritt wird FHEM doch eine geiwsse Zeit brauchen, bis entsprechend der Notify zu schlägt. Bei einer solchen Situation würde ich immer dafür sorgen, dass direkt an der Schaltung sichergestellt ist, dass keine Fehlschaltung erfolgen kann. Ich kenne natürlich Deine Motoren und die Schaltung nicht, aber wenn wirklich ein Motorschutz notwendig ist, dann sollte der in die Hardware wandern.

Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

fhemer

Habe es jetzt mal ausgedruckt und konnte keinen Unterscheid finden. Auch nicht in der Hardware. Wir haben also ein Problem :-) Entweder ein Bug in FHEM (I2C Implementierung), was ich aber nicht glaube oder das IC (das I2C IC :-) hat einen Schlag weg. Deswegen die Frage: Woher genau erhält FHEM den Status des Ausgangs? Wird das über den I2C Bus angefragt (eher nicht oder?) oder merkt sich FHEM intern, was Phase am Ausgang ist? Der gute Entwickler weiß die Antwort bestimmt aus dem ff :-)

Ja, stimmt, sollte man in der Hardware machen. Aber der Rollladenmotor hat nochmal eine eigene Elektronik und läuft sowieso erst nach 1 Sekunde los. Es ist nur ein zusätzlicher Schutz.

viegener

Ist denn nur das Icon falsch oder auch der Status am Device selber?

Ich würde jetzt Schritt für Schritt vorgehen bevor gleich ein Fehler in FHEM oder der HW vermutet wird.
Also ausserhalb der ganzen Readingproxies etc, also ganz ohne irgendeine Automatik (alle diese Devices kurzzeitig komplett entfernen und nur den I2C-Device erhalten ohne notfies und weitere Automatik-Attribute)

Schalte den Ausgang PortA1 an / aus und schaue wie in FHEM der STatus sich ändert.
Wenn das nicht geht (HW ?) oder der Status nicht stimmt (Einrichtung oder HW) kann man von da aus ausgehen.
Ohne funktionierendes Grundgerüst, kommst Du mit den ganzen proxies, notifes etc nur ins Chaos

Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

fhemer

#6
Zu Frage 1 (ein Bild sagt mehr als 1000 Worte). Auch physikalisch ist der Ausgang super (Verbraucher ist aus, so wie es sein soll)! Nur state steht noch auf on.

siehe Readings A1.png

viegener

Also ist der Status am Gerät falsch?

Dann wiederhole ich meine Empfehlung erstmal das gesamte Kunstwerk drumherum zu entfernen und zu schauen, ob das Device wirklich nicht funktioniert.
Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

fhemer

Die Hardware und die Anzeige funktionieren jetzt, mit diesem Code:
Was nun???


attr global logfile ./log/fhem-%Y-%m.log
attr global modpath .
attr global statefile ./log/fhem.save
attr global verbose 3
attr global updateInBackground
attr global latitude 50.111
attr global longitude 8.682

define telnetPort telnet 7072 global

define WEB FHEMWEB 8083 global

define WEBphone FHEMWEB 8084 global
attr WEBphone stylesheetPrefix smallscreen

define WEBtablet FHEMWEB 8085 global
attr WEBtablet stylesheetPrefix touchpad

# Fake FileLog entry, to access the fhem log from FHEMWEB
define Logfile FileLog ./log/fhem-%Y-%m.log fakelog

define autocreate autocreate
attr autocreate filelog ./log/%NAME-%Y.log

define eventTypes eventTypes ./log/eventTypes.txt

# Disable this to avoid looking for new USB devices on startup
define initialUsbCheck notify global:INITIALIZED usb create


define i2c RPII2C 1
attr i2c alias Onboard I2C Controller 1
attr i2c room ops

define i2c20 I2C_MCP23017 0x20
attr i2c20 IODev i2c
attr i2c20 room ops
attr i2c20 OutputPorts A0,A1,A2,A3,A4,A5,A6,A7,B0,B1,B2,B3,B4,B5,B6,B7
set i2c20 PortB0 off # ausschalten
set i2c20 PortA0 off # ausschalten
set i2c20 PortA1 off
set i2c20 PortA2 off

define i2c20pA1 readingsProxy i2c20:PortA1
attr i2c20pA1 room ops
attr i2c20pA1 devStateIcon on:on:off off:off:on
attr i2c20pA1 alias AZ Rolladen 2 hoch
attr i2c20pA1 setList on off
attr i2c20pA1 setFn {($CMD eq "on")?"PortA1 on":"PortA1 off"}
attr i2c20pA1 webCmd on:off:on-for-timer 10

define i2c20pA2 readingsProxy i2c20:PortA2
attr i2c20pA2 room ops
attr i2c20pA2 devStateIcon on:on:off off:off:on
attr i2c20pA2 alias AZ Rolladen 2 runter
attr i2c20pA2 setList on off
attr i2c20pA2 setFn {($CMD eq "on")?"PortA2 on":"PortA2 off"}
attr i2c20pA2 webCmd on:off:on-for-timer 10



viegener

OK, wenn das geht, würde ich wie gesagt Schritt-Für-Schritt jeweils mehr wieder hinzufügen und jeweils überprüfen ob das verhalten korrekt bleibt
Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

fhemer



define SchutzA1 notify i2c20pA2:on set i2c20pA1 off
define SchutzA2 notify i2c20pA1:on set i2c20pA2 off



Somit haben wir wieder das Problem! Ist da was falsch geschrieben?


igami

Pi3 mit fhem.cfg + DbLog/logProxy
Komm vorbei zum FHEM Treffen im Kreis Gütersloh! Das nächste Mal im April 2020.

MAINTAINER: archetype, LuftdatenInfo, monitoring, msgDialog, Nmap, powerMap
ToDo: AVScene, FluxLED

fhemer

#12
2016-05-19 21:20:14 readingsProxy i2c20pA1 on
2016-05-19 21:20:14 I2C_MCP23017 i2c20 PortA1: on
2016-05-19 21:20:14 I2C_MCP23017 i2c20 Ok
2016-05-19 21:20:14 I2C_MCP23017 i2c20 Ok
2016-05-19 21:20:14 I2C_MCP23017 i2c20 Ok
2016-05-19 21:20:14 I2C_MCP23017 i2c20 Ok
2016-05-19 21:20:17 readingsProxy i2c20pA2 on
2016-05-19 21:20:17 I2C_MCP23017 i2c20 PortA2: on
2016-05-19 21:20:17 I2C_MCP23017 i2c20 PortA1: off
2016-05-19 21:20:17 I2C_MCP23017 i2c20 Ok
2016-05-19 21:20:17 I2C_MCP23017 i2c20 Ok
2016-05-19 21:20:17 I2C_MCP23017 i2c20 Ok
2016-05-19 21:20:17 I2C_MCP23017 i2c20 Ok

Draußen in der Wirklichkeit ist alles korrekt!

igami

Ich sehe da kein "i2c20pA2:on", sondern ein "i2c20 PortA2: on" oder ein "i2c20pA2 on"
Pi3 mit fhem.cfg + DbLog/logProxy
Komm vorbei zum FHEM Treffen im Kreis Gütersloh! Das nächste Mal im April 2020.

MAINTAINER: archetype, LuftdatenInfo, monitoring, msgDialog, Nmap, powerMap
ToDo: AVScene, FluxLED

fhemer

Zitat von: igami am 19 Mai 2016, 21:32:14
Ich sehe da kein "i2c20pA2:on", sondern ein "i2c20 PortA2: on" oder ein "i2c20pA2 on"

Was möchtest Du damit sagen? Ist der Code (siehe oben) falsch? Wie gesagt, nach draußen funktioniert ja alles völlig korrekt. D.h. doch, der Code ist korrekt und FHEM hat einen Bug! Habe eben alles mal von Port A auf B abgeändert, gleiche Reaktion der Icons.