[Anleitung, gelöst] Dyson Air Ventilator einbinden

Begonnen von eddy242, 02 Dezember 2018, 16:45:45

Vorheriges Thema - Nächstes Thema

Shadow3561

Hallo,
ich habe diesen Dyson
https://shop.dyson.de/ventilatoren-und-heizluefter/luftreiniger/dyson-pure-cool-tower-310130-01

Auf diesem Gerät ist, wie gesagt, kein Aufkleber mit einem Wlan-Passwort. Auch in der Beschreibung ist keines vorhanden.
Man benötigt aber auch keines um ihn ins Heimnetz zu integrieren. Das macht die App alles irgendwie automatisch.

Kannst du mir ein wenig auf die Sprünge helfen wie ich, die von dir erwähnte, lib ausführe?

https://github.com/patrickvaler/dyson-cloud
Ich habe nur noch die Entschlüsselung genutzt, aber für dich wäre es bestimmt einfacher sie gleich zu nutzen. Benötigt wird Note.js


MfG

Blackcat

Das ist der neue TP04. Dieser unterscheided sich etwas von den Messages was ich herausfinden konnte.

Als erstes benötigst du Node.js auf deinem Rechner:
https://docs.microsoft.com/de-de/windows/nodejs/setup-on-windows
Schritte 1-11.

Dann legst du irgendwo einen Ordner an. z.B. C:\dyson
Öffne nun cmd und navigiere zum Ordner (cd C:\dyson).
dann die lib laden:
npm install --save dyson-cloud
sollte jetzt im Ordner sein

als letztes eine Datei (dysonabfrage.js) anlegen (Mail und PW ändern):
const DysonCloud = require('dyson-cloud');
const myAccount = new DysonCloud("<dysonemail>","<dysonpwimklartext");

myAccount.getDevices()
  .then(devices => console.log(devices));

und ausführen in der noch offnen cmd:
node dysonabfrage.js

weitere hilfreiche Seite: https://glossar.hs-augsburg.de/Node.js-Tutorium:_Hello_World:_Konsole

@CoolTux
Ja das habe ich gestern Nacht noch gemacht, Kelvin ist zwar auch ganz nett aber Celsius ist mir lieber

PS: im Anhang mal meine entschlüsselten Readings so far
Viele Grüße Sandra - FHEM Style Entwicklerin iOS6+12
-----
ZBox nano, Homematic, Homebridge, Hue + Mi Light, ZWave, Dyson, etc.
https://www.foodcat.de
https://www.youtube.com/c/FoodCat (hier gibt es auch immer mehr Hausautomatisierungsvideos)

Shadow3561

Danke Sandra für deine ausführliche Hilfestellung.

Leider funktioniert es bei mir weder in Windows noch Ubuntu.

Die Fehlermeldung lauten bei beiden Systemen identisch.

/root/node_modules/dyson-cloud$ node dysonabfrage.js
(node:5222) UnhandledPromiseRejectionWarning: #<Object>
(node:5222) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:5222) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


MfG

Blackcat

das Script scheint bei dir in der lib zu liegen und das mag er nicht.

so müsste der Aufbau der Ordner aussehen (nicht wundern bei mir heißen die Dateien anders)
Viele Grüße Sandra - FHEM Style Entwicklerin iOS6+12
-----
ZBox nano, Homematic, Homebridge, Hue + Mi Light, ZWave, Dyson, etc.
https://www.foodcat.de
https://www.youtube.com/c/FoodCat (hier gibt es auch immer mehr Hausautomatisierungsvideos)

Blackcat

Kann mir jemand weiterhelfen wie man die SetList von MQTT2 Devices nutzt?

mit MQTT.fx kann ich ein json publishen, in FHEM will das aber so nicht
attr sz_dyson_device_tp02 setList publish 475/.../command {"msg":"STATE-SET","time":"2019-12-29T23:01:30.063Z","mode-reason":"LAPP","data":{"fmod":"OFF"}}
habe es auch schon mit $EVENT versucht

ist mein erstes Device mit MQTT also seid nachsichtig für meine Fragen ::)
Viele Grüße Sandra - FHEM Style Entwicklerin iOS6+12
-----
ZBox nano, Homematic, Homebridge, Hue + Mi Light, ZWave, Dyson, etc.
https://www.foodcat.de
https://www.youtube.com/c/FoodCat (hier gibt es auch immer mehr Hausautomatisierungsvideos)

Shadow3561

#20
Das erstellte Script "dysonabfrage" liegt nicht im lib-Ordner.

Zitatroot@nuc-server:~/node_modules/dyson-cloud# ls
CONTRIBUTING.md  dysonabfrage.js  index.js  lib  LICENSE.md  node_modules  package.json  README.md
root@nuc-server:~/node_modules/dyson-cloud#

Edit: Ein Neustart vom Server hat geholfen.

Danke

rudolfkoenig

Zitatin FHEM will das aber so nicht
Was genau heisst das?

Mit dem gezeigten attr erscheint bei mir nach "set sz_dyson_device_tp02 publish" Folgendes:
% mosquitto_sub -t # -v
475/.../command {"msg":"STATE-SET","time":"2019-12-29T23:01:30.063Z","mode-reason":"LAPP","data":{"fmod":"OFF"}}

Blackcat

#22
hm.. brauche ich zum Senden dann einen Mosquitto?
Der Dyson hat einen Server incl. deshalb habe ich nur einen MQTT2_CLIENT und dann das MQTT2_DEVICE.

das kommt bei versose 5 wenn ich drücke, aber der befehl kommt am Gerät nicht an.

2019.12.30 16:49:35 4: MQTT2_DEVICE_Parse: sz_dyson_device_tp02 475/<Dysonserial>/command => command
2019.12.30 16:49:35 4: MQTT2_DEVICE_Parse: sz_dyson_device_tp02 475/<Dysonserial>/status/current => current
2019.12.30 16:49:54 4: MQTT2_DEVICE_Parse: sz_dyson_device_tp02 475/<Dysonserial>/command => command
2019.12.30 16:49:54 4: MQTT2_DEVICE_Parse: sz_dyson_device_tp02 475/<Dysonserial>/status/current => current


Die Readinglist geht z.B. super:
attr sz_dyson_device_tp02 readingList 475/<Dysonserial>/command:.* command\
475/<Dysonserial>/status/current:.* current\
475/<Dysonserial>/status/connection:.* connection\
475/<Dysonserial>/status/faults:.* faults\
475/<Dysonserial>/status/software:.* software\
475/<Dysonserial>/status/summary:.* summary


ich tippe einfach nur drauf dass ich irgendwie die Syntax zum Senden falsch habe, komisch nur dass kein Fehler kommt


@Shadow: hast du ein Device als Antwort bekommen, dass ein PW hat?
Viele Grüße Sandra - FHEM Style Entwicklerin iOS6+12
-----
ZBox nano, Homematic, Homebridge, Hue + Mi Light, ZWave, Dyson, etc.
https://www.foodcat.de
https://www.youtube.com/c/FoodCat (hier gibt es auch immer mehr Hausautomatisierungsvideos)

Blackcat

#23
ich habe das attr noch mal gelöscht und neu eingeben, siehe da es geht  ::)

Jetzt nur noch die nächste Hürde:
set sz_dyson_device_tp02 publish {...JSON...}

wäre das dann
attr sz_dyson_device_tp02 setList publish 475/<serial>/command $EVENT
oder
attr sz_dyson_device_tp02 setList publish 475/<serial>/command $EVTPART0

Ziel wäre der Aufruf (ggf. ist der aber falsch)
set sz_dyson_device_tp02 publish {dyson_json_compose("fnsp", "10")}


----
Problem war wirklich der Befehl  ::)
{fhem("set sz_dyson_device_tp02 publish ".dyson_json_compose("fnsp", "10"))} hiermit geht es :)
plus:
attr sz_dyson_device_tp02 setList publish 475/<serial>/command
Viele Grüße Sandra - FHEM Style Entwicklerin iOS6+12
-----
ZBox nano, Homematic, Homebridge, Hue + Mi Light, ZWave, Dyson, etc.
https://www.foodcat.de
https://www.youtube.com/c/FoodCat (hier gibt es auch immer mehr Hausautomatisierungsvideos)

moppy

Zitat von: Blackcat am 30 Dezember 2019, 17:11:43
ich habe das attr noch mal gelöscht und neu eingeben, siehe da es geht  ::)

Jetzt nur noch die nächste Hürde:
set sz_dyson_device_tp02 publish {...JSON...}

wäre das dann
attr sz_dyson_device_tp02 setList publish 475/<serial>/command $EVENT
oder
attr sz_dyson_device_tp02 setList publish 475/<serial>/command $EVTPART0

Ziel wäre der Aufruf (ggf. ist der aber falsch)
set sz_dyson_device_tp02 publish {dyson_json_compose("fnsp", "10")}


----
Problem war wirklich der Befehl  ::)
{fhem("set sz_dyson_device_tp02 publish ".dyson_json_compose("fnsp", "10"))} hiermit geht es :)
plus:
attr sz_dyson_device_tp02 setList publish 475/<serial>/command

Hallo Blackcat, ich bin auch gerade dabei den Dyson Pure Cool mittels MQTT2 einzubinden, ich scheitere jedoch. Kannst du deine komplette Konfiguration posten? Der MQTT2_Client springt bei mir zwischen "opened" und "disconnected" hin und her. im MQTT2_DEVICE habe ich das attribut setList publish 475/meine_seriennummer/command eingebunden.

lg, Emanuel
Intel NUC7i5 - Proxmox
HP Microserver Gen8 3,3ghz Xeon
http://coldcorner.de

Blackcat

#25
Hi Emanuel,

hier meine laufende Umgebung, leider aber noch nicht ganz perfekt, wollte noch wechselnde Statusicons und eine Sycronisation zu den Steuerungsbuttons machen. Eigentlich wollte ich auch noch einen Blogbeitrag mit Tutorial schreiben  ::) bin aber bisher nicht dazu gekommen

Habe eine eigene Abruffunktion gebaut und nur eddys composer angepasst, damit es läuft.

Hier mal alle configs, serial jeweil anpassen:

define sz_dyson_device_tp02 MQTT2_DEVICE
attr sz_dyson_device_tp02 IODev Dyson_broker
attr sz_dyson_device_tp02 alias Dyson TP02
attr sz_dyson_device_tp02 event-on-change-reading .*
attr sz_dyson_device_tp02 event-on-update-reading .*
attr sz_dyson_device_tp02 group Schlafzimmer
attr sz_dyson_device_tp02 icon dyson-tp02
attr sz_dyson_device_tp02 readingList 475/serial/command:.* command\
475/serial/status/current:.* current\
475/serial/status/connection:.* connection\
475/serial/status/faults:.* faults\
475/serial/status/software:.* software\
475/serial/status/summary:.* summary
attr sz_dyson_device_tp02 room Lüftung
attr sz_dyson_device_tp02 setList publish 475/serial/command
attr sz_dyson_device_tp02 stateFormat {"M: " . ReadingsVal($name,"fan_mode",0) . "  S: " . ReadingsVal($name,"fan_speed",0) }
attr sz_dyson_device_tp02 verbose 5

define FileLog_sz_dyson_device_tp02 FileLog ./log/sz_dyson_device_tp02-%Y-%m.log sz_dyson_device_tp02:dust:.*|sz_dyson_device_tp02:fan_speed:.*|sz_dyson_device_tp02:filter_life:.*|sz_dyson_device_tp02:humidity:.*|sz_dyson_device_tp02:quality_target:.*|sz_dyson_device_tp02:temperature:.*|sz_dyson_device_tp02:volatil_organic_compounds:.*
attr FileLog_sz_dyson_device_tp02 logtype text
attr FileLog_sz_dyson_device_tp02 room hidden

define DOIF_update_Dyson DOIF ([$SELF:desired_fanspeed])\
(\
setreading $SELF desired_mode FAN;;\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_fanspeed];;\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_mode];;\
sleep 1;;\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_statusrequest];; \
)\
DOELSEIF ([$SELF:desired_oscillation])\
(\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_oscillation];;\
sleep 1;;\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_statusrequest];; \
)\
DOELSEIF ([$SELF:desired_mode])\
(\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_mode];;\
sleep 1;;\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_statusrequest];; \
)\
DOELSEIF (\
(([sz_dyson_device_tp02:fan_mode] eq "FAN") or \
([sz_dyson_device_tp02:fan_mode] eq "AUTO") or \
([sz_dyson_device_tp02:fan_mode] eq "OFF"))\
) (\
setreading $SELF desired_fanspeed [sz_dyson_device_tp02:fan_speed];;\
setreading $SELF desired_oscillation [sz_dyson_device_tp02:oscillation];;\
setreading $SELF desired_mode [sz_dyson_device_tp02:fan_mode];;\
)
attr DOIF_update_Dyson alias Dyson TP02
attr DOIF_update_Dyson cmdState set_fanspeed|set_oscillation|set_mode|stat_AnLow|stat_AnMedium|stat_AnHigh|stat_Off
attr DOIF_update_Dyson devStateIcon set_.*:Ventilator_fett
attr DOIF_update_Dyson do always
attr DOIF_update_Dyson group Schlafzimmer
attr DOIF_update_Dyson icon dyson-tp02
attr DOIF_update_Dyson readingList desired_fanspeed,desired_oscillation,desired_mode
attr DOIF_update_Dyson room Lüftung
attr DOIF_update_Dyson setList desired_fanspeed:slider,1,1,10 desired_oscillation:ON,OFF desired_mode:FAN,AUTO,OFF
attr DOIF_update_Dyson userReadings command_JSON_fanspeed { (dyson_json_compose("fnsp", ReadingsVal("$NAME", "desired_fanspeed", "1"))) }, \
command_JSON_oscillation { (dyson_json_compose("oson", ReadingsVal("$NAME", "desired_oscillation", "OFF"))) }, \
command_JSON_mode { (dyson_json_compose("fmod", ReadingsVal("$NAME", "desired_mode", "OFF"))) },\
command_JSON_staterequest { (dyson_json_compose("sreq", "dummy")) },\
command_JSON_environmentrequest { (dyson_json_compose("ereq", "dummy")) }
attr DOIF_update_Dyson webCmd desired_fanspeed:desired_oscillation:desired_mode

define Dyson_Notify notify sz_dyson_device_tp02:.* {dyson_json_read_current("sz_dyson_device_tp02","sz_dyson_doif_tp02")}

define mqtt_status_request at +*00:02:00 {fhem("set sz_dyson_device_tp02 publish ".dyson_json_compose("ereq", "10"));;fhem("set sz_dyson_device_tp02 publish ".dyson_json_compose("sreq", "10"))}
attr mqtt_status_request alias Dyson MQTT Status Request
attr mqtt_status_request group Steuerung - Dyson
attr mqtt_status_request icon dyson-tp02
attr mqtt_status_request room Steuerung

define SVG_FileLog_sz_dyson_device_tp02_1 SVG FileLog_sz_dyson_device_tp02:SVG_FileLog_sz_dyson_device_tp02_1:CURRENT
attr SVG_FileLog_sz_dyson_device_tp02_1 group Schlafzimmer
attr SVG_FileLog_sz_dyson_device_tp02_1 room Lüftung


meine 99_myUtilsDyson.pm:
######################################################
########   
######## Dyson TP02 Integration - Sandra Ohmayer (Blackcat) foodcat.de
########         
######################################################
use JSON;

## dyson_json_read_current(mqtt2_device)
sub
dyson_json_read_current {
# Dyson MQTT2 Device
    my $device = $_[0];

my $currentJsonString = ReadingsVal($device, "current", "{}");
my $currentObj = decode_json($currentJsonString);

if ($currentObj->{msg} eq "ENVIRONMENTAL-CURRENT-SENSOR-DATA") {
my $humidity = $currentObj->{data}->{hact};
if ($humidity eq "OFF") {
$humidity = 0;
}
fhem("setreading ".$device." humidity ".($humidity+0));

my $volatil_organic_compounds = $currentObj->{data}->{vact};
if ($volatil_organic_compounds eq "INIT") {
$volatil_organic_compounds = 0;
}
fhem("setreading ".$device." volatil_organic_compounds ".($volatil_organic_compounds+0));

my $temperature = $currentObj->{data}->{tact};
if ($temperature eq "OFF") {
$temperature = 0;
} else {
$temperature = ($temperature/10)-273.15;
}
fhem("setreading ".$device." temperature ".$temperature);

my $dust = $currentObj->{data}->{pact};
fhem("setreading ".$device." dust ".($dust+0));

my $sleep_timer = $currentObj->{data}->{sltm};
if ($sleep_timer ne "OFF") {
$sleep_timer = $sleep_timer+0;
}
fhem("setreading ".$device." sleep_timer ".$sleep_timer);
}
if ($currentObj->{msg} eq "STATE-CHANGE") {
my $fan_mode = $currentObj->{"product-state"}->{fmod}->[1];
fhem("setreading ".$device." fan_mode ".$fan_mode); #OFF, AUTO, FAN

my $fan_state = $currentObj->{"product-state"}->{fnst}->[1];
fhem("setreading ".$device." fan_state ".$fan_state); #Running yes:FAN no:OFF

my $fan_speed = $currentObj->{"product-state"}->{fnsp}->[1];
fhem("setreading ".$device." fan_speed ".($fan_speed+0)); #1-10

my $quality_target = $currentObj->{"product-state"}->{qtar}->[1];
fhem("setreading ".$device." quality_target ".($quality_target+0));

my $oscillation = $currentObj->{"product-state"}->{oson}->[1];
fhem("setreading ".$device." oscillation ".$oscillation);

my $standby_monitoring = $currentObj->{"product-state"}->{rhtm}->[1];
fhem("setreading ".$device." standby_monitoring ".$standby_monitoring); #ON, OFF

my $filter_life = $currentObj->{"product-state"}->{filf}->[1];
fhem("setreading ".$device." filter_life ".$filter_life);

my $ercd = $currentObj->{"product-state"}->{ercd}->[1];
fhem("setreading ".$device." ercd ".$ercd);  #?????????????????

my $night_mode = $currentObj->{"product-state"}->{nmod}->[1];
fhem("setreading ".$device." night_mode ".$night_mode); #ON, OFF

my $wacd = $currentObj->{"product-state"}->{wacd}->[1];
fhem("setreading ".$device." wacd ".$wacd); #?????????????????
}
}

######################################################
########   
######## Dyson command string composer - eddy242 last edit Sandra Ohmayer (Blackcat)
########         
######################################################


sub dyson_json_compose {
my ($command,$value) = @_;

# das spezielle Format für die Zeit im JSON für den Dyson
my $t = time;
my $date = strftime "%Y-%m-%dT%H:%M:%S", gmtime $t;
$date .= sprintf ".%03dZ", ($t-int($t))*1000; # without rounding

my $commandString = "{\"msg\":\"STATE-SET\",\"time\":\"".$date."\",\"mode-reason\":\"LAPP\""; # der erste Teil ist immer Kommando & Datum

if   ($command eq "fmod") { $commandString .= ",\"data\":{\"fmod\":\"".$value."\"}"} # Fan-Mode, VALID: OFF, AUTO, FAN
elsif ($command eq "fnsp") { $commandString .= ",\"data\":{\"fnsp\":\"".$value."\"}"} # Fan-Speed, VALID: 1..10
elsif ($command eq "qtar") { $commandString .= ",\"data\":{\"qtar\":\"".$value."\"}"} # Quality?
elsif ($command eq "nmod") { $commandString .= ",\"data\":{\"nmod\":\"".$value."\"}"} # nmod?
elsif ($command eq "oson") { $commandString .= ",\"data\":{\"oson\":\"".$value."\"}"} # Oszillation, VALID: OFF, ON
elsif ($command eq "rhtm") { $commandString .= ",\"data\":{\"fmod\":\"FAN\", \"rhtm\":\"".$value."\", }"} # Fan-Mode + rhtm?, VALID (Fan-Mode: OFF, AUTO, FAN) + (rhtm: OFF, ON)
else { $commandString .= ",\"data\":{\"fmod\":\"OFF\"}" }; # notfalls aus

# und noch die Klammer zu
$commandString .= "}";

# Wenn das Kommando Status Request war ist der Commandstring simpel
if ($command eq "sreq") { $commandString = "{\"msg\":\"REQUEST-CURRENT-STATE\",\"time\":\"".$date."\"}"};
if ($command eq "ereq") { $commandString = "{\"msg\":\"REQUEST-PRODUCT-ENVIRONMENT-CURRENT-SENSOR-DATA\",\"time\":\"".$date."\"}"};

Log3 (undef, 3, $commandString);
return $commandString;
}


wenn das nicht geht, setzte den Dyson zurück auf Werkseinstellungen und verbinde ihn neu mit dem WLAN, bei mir war das am Anfang auch ein Problem  mit Abbrüchen

PS: so sieht das ganze dann laufend aus. Das svg icon habe ich auch erstellt, jedoch ist es auch noch nicht perfekt (da es immer schwarz bleibt), wenn ich fertig bin lade ich alles dann im Blog hoch und verlinke es hier  ;)
Viele Grüße Sandra - FHEM Style Entwicklerin iOS6+12
-----
ZBox nano, Homematic, Homebridge, Hue + Mi Light, ZWave, Dyson, etc.
https://www.foodcat.de
https://www.youtube.com/c/FoodCat (hier gibt es auch immer mehr Hausautomatisierungsvideos)

Shadow3561

#26
Ich habe es jetzt vergeblich versucht.

Bekomme meinen Dyson TP04 einfach nicht eingebunden.

Habe alles gemacht wie im 1.Post aber kann den Dyson weder steuern noch bekomme ich den Status angezeigt.
Ich habe mit Wireshark den Username und das Passwort rausgefunden und alle "469/NB2-EU-HEA4515A" durch "438/VS9-EU-KHB1111A" ersetzt,
aber leider ohne Erfolg.

Mqtt läuft auf dem Server und ich steuere damit bereits meine Shelly-Devices.
Hat schon jemand einen 438 zum laufen bekommen? Wenn ja, wie?

Langsam verzweifele ich. :'(

Dies kommt vom Dyson beim Statusrequest

438/serial/status/current{"msg":"CURRENT-STATE","time":"2020-05-28T17:02:17.000Z","mode-reason":"PRC",
"state-reason":"MODE","rssi":"-52","channel":"108","fqhp":"103888","fghp":"0","product-state":
{"fpwr":"OFF","auto":"ON","oscs":"OFF","oson":"ON","nmod":"ON","rhtm":"ON","fnst":"OFF","ercd":"NONE","wacd":
"NONE","nmdv":"0004","fnsp":"AUTO","bril":"0002","corf":"ON","cflr":"0100","hflr":"0100","cflt":"CARF","hflt":
"GHEP","sltm":"OFF","osal":"0115","osau":"0160","ancp":"0090","fdir":"OFF"},"scheduler":
{"srsc":"0000000000000000","dstv":"0001","tzid":"0001"}}


und dies

438/serial/command{
  "mode-reason": "LAPP",
  "time": "2020-05-28T17:02:18Z",
  "msg": "REQUEST-CURRENT-STATE"
}438/serial/command{
  "mode-reason": "LAPP",
  "time": "2020-05-28T17:02:18Z",
  "msg": "REQUEST-PRODUCT-ENVIRONMENT-CURRENT-SENSOR-DATA"
}438/Vserial/command{
  "mode-reason": "LAPP",
  "time": "2020-05-28T17:02:18Z",
  "msg": "REQUEST-CURRENT-FAULTS"
}438/serial/command{
  "mode-reason": "LAPP",
  "time": "2020-05-28T17:02:18Z",
  "msg": "REQUEST-CURRENT-STATE



Kann damit jemand etwas anfangen?

Hier eine MQTT message wenn ich den Lüfter einschalte
438/VS9-EU-KHB1111A/command {
  "data": {
    "fpwr": "ON"
  },
  "mode-reason": "LAPP",
  "time": "2020-05-28T17:02:23Z",
  "msg": "STATE-SET"
}




Mit freundlichen Grüßen

Shadow3561

#27
So,

ich habe es geschafft meinen TP04 einzubinden.

Hier meine laufende Config.
Leider lässt sich beim DOIF zwar der Fan steuern, aber wenn man mit der Handy-App was ändert, ändert sich der Status im DOIF nicht.


Als 1. das Passwort besorgen (steht leider beim TP04 nirgends drauf).
Ich habe mit der Handy-App "tPacketCapture" den Datenverkehr gesnifft und die entstandene Datei dann mit "Wireshark" am Macbook importiert.
Dann nach MQTT-Protokol gefiltert und nach "Connect Command" gesucht.
Dann ist der Username und das Passwort im Klartext sichtbar.
Beides notieren, es wird für den MQTT2-Client benötigt.

define dyson_broker_mqtt2 MQTT2_CLIENT <IP-vom-Lüfter:1883>
attr dyson_broker_mqtt2 autocreate simple
attr dyson_broker_mqtt2 keepaliveTimeout 5
attr dyson_broker_mqtt2 mqttVersion 3.1.1
attr dyson_broker_mqtt2 rawEvents 1
attr dyson_broker_mqtt2 room mqtt
attr dyson_broker_mqtt2 subscriptions 438/VS9-EU-KHB1111A/status/current
attr dyson_broker_mqtt2 username XXX-XX-XXXXXXXX  #hier der username den ihr notiert habt
attr dyson_broker_mqtt2 verbose 0


jetzt noch ein "set dyson_broker_mqtt2 password <notiertes Passwort>" in der fhem-Eingabezeile

Jetzt den Lüfter

define sz_dyson_device_tp02 MQTT2_DEVICE
attr sz_dyson_device_tp02 DbLogExclude .*
attr sz_dyson_device_tp02 IODev dyson_broker_mqtt2
attr sz_dyson_device_tp02 alias Dyson TP02
attr sz_dyson_device_tp02 autocreate 1
attr sz_dyson_device_tp02 event-on-change-reading .*
attr sz_dyson_device_tp02 event-on-update-reading .*
attr sz_dyson_device_tp02 icon dyson-tp02
attr sz_dyson_device_tp02 readingList 438/XXX-XX-XXXXXXXX/status/current:.* current
attr sz_dyson_device_tp02 room mqtt
attr sz_dyson_device_tp02 setList publish 438/XXX-XX-XXXXXXXX/command
attr sz_dyson_device_tp02 stateFormat {"Power: " . ReadingsVal($name,"dy_fan_state",0) . "  Fanspeed: " . ReadingsVal($name,"dy_fan_speed",0) }
attr sz_dyson_device_tp02 verbose 0



Als Nächstes das Dorf zum steuern des Lüfters


define DOIF_update_Dyson DOIF ([$SELF:desired_fanspeed])\
(\
\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_fanspeed];;\
      sleep 1;;\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_staterequest];; \
)\
DOELSEIF ([$SELF:desired_oscillation])\
(\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_oscillation];;\
sleep 1;;\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_staterequest];; \
)\
DOELSEIF ([$SELF:desired_auto])\
(\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_auto];;\
sleep 1;;\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_staterequest];; \
)\
DOELSEIF ([$SELF:desired_mode])\
(\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_mode];;\
sleep 1;;\
set sz_dyson_device_tp02 publish [$SELF:command_JSON_staterequest];; \
)\
DOELSEIF (\
(([sz_dyson_device_tp02:dy_fan_state] eq "ON") or \
([sz_dyson_device_tp02:dy_fan_state] eq "OFF"))\
) (\
setreading $SELF desired_fanspeed [sz_dyson_device_tp02:dy_fan_speed:d];;\
setreading $SELF desired_oscillation [sz_dyson_device_tp02:dy_fan_oszilation:d];;\
setreading $SELF desired_mode [sz_dyson_device_tp02:dy_fan_state:d];;\
        setreading $SELF desired_auto [sz_dyson_device_tp02:dy_fan_auto:d];;\
)
attr DOIF_update_Dyson alias Dyson
attr DOIF_update_Dyson cmdState set_fanspeed|set_auto|set_oscillation|set_mode
attr DOIF_update_Dyson devStateIcon set_.*:Ventilator_fett
attr DOIF_update_Dyson do always
attr DOIF_update_Dyson icon dyson-tp02
attr DOIF_update_Dyson readingList desired_fanspeed,desired_auto,desired_oscillation,desired_mode
attr DOIF_update_Dyson room Schlafzimmer,mqtt
attr DOIF_update_Dyson setList desired_fanspeed:slider,1,1,10 desired_auto:ON,OFF desired_oscillation:ON,OFF desired_mode:ON,OFF
attr DOIF_update_Dyson userReadings command_JSON_fanspeed { (dyson_json_compose("fnsp", ReadingsVal("$NAME", "desired_fanspeed", "1"))) }, \
command_JSON_auto { (dyson_json_compose("auto", ReadingsVal("$NAME", "desired_auto", "OFF"))) },\
command_JSON_oscillation { (dyson_json_compose("oson", ReadingsVal("$NAME", "desired_oscillation", "OFF"))) }, \
command_JSON_mode { (dyson_json_compose("fpwr", ReadingsVal("$NAME", "desired_mode", "OFF"))) },\
command_JSON_staterequest { (dyson_json_compose("sreq", "dummy")) },\
command_JSON_environmentrequest { (dyson_json_compose("ereq", "dummy"))}\
attr DOIF_update_Dyson verbose 0
attr DOIF_update_Dyson webCmd desired_fanspeed:desired_auto:desired_oscillation:desired_mode


dann noch DOIF und notify

define Dyson_Notify notify sz_dyson_device_tp02:.* {dyson_json_read_current("sz_dyson_device_tp02","DOIF_update_Dyson")}
attr Dyson_Notify room mqtt
attr Dyson_Notify verbose 0

define mqtt_status_request at +*00:02:00 {fhem("set sz_dyson_device_tp02 publish ".dyson_json_compose("ereq", "10"));;;;fhem("set sz_dyson_device_tp02 publish ".dyson_json_compose("sreq", "10"))}
attr mqtt_status_request alias Dyson MQTT Status Request
attr mqtt_status_request icon dyson-tp02
attr mqtt_status_request room mqtt
attr mqtt_status_request verbose 0


Dann muss noch ein Teil in die 99_myUtils.pm damit das MQTT2-Device. Hier musste ich für den TP04 einiges ändern weil die MQTT-Requests und die MQTT-Commands wohl bei den neuen Modellen geändert wurden.

######################################################
########   
######## Dyson TP02 Integration - Sandra Ohmayer (Blackcat) foodcat.de
########         
######################################################
use JSON;

## dyson_json_read_current(mqtt2_device)
sub
dyson_json_read_current {
# Dyson MQTT2 Device
    my $device = $_[0];

my $currentJsonString = ReadingsVal($device, "current", "{}");
my $currentObj = decode_json($currentJsonString);

if ($currentObj->{msg} eq "ENVIRONMENTAL-CURRENT-SENSOR-DATA") {
my $humidity = $currentObj->{data}->{hact};
if ($humidity eq "OFF") {
$humidity = 0;
}
fhem("setreading ".$device." dy_humidity ".($humidity+0));

my $volatil_organic_compounds = $currentObj->{data}->{va10};
if ($volatil_organic_compounds eq "INIT") {
$volatil_organic_compounds = 0;
}
fhem("setreading ".$device." dy_VOCs ".($volatil_organic_compounds+0));

my $temperature = $currentObj->{data}->{tact};
if ($temperature eq "OFF") {
$temperature = 0;
} else {
$temperature = ($temperature/10)-273.15;
}
fhem("setreading ".$device." dy_temperature ".$temperature);

my $pm10 = $currentObj->{data}->{pm10};
fhem("setreading ".$device." dy_pm10 ".($pm10+0));

my $pm25 = $currentObj->{data}->{pm25};
fhem("setreading ".$device." dy_pm2.5 ".($pm25+0));

my $va10 = $currentObj->{data}->{va10};
fhem("setreading ".$device." dy_va10 ".($va10+0));

my $noxl = $currentObj->{data}->{noxl};
fhem("setreading ".$device." dy_NOx ".($noxl+0));



my $sleep_timer = $currentObj->{data}->{sltm};
if ($sleep_timer ne "OFF") {
$sleep_timer = $sleep_timer+0;
}
fhem("setreading ".$device." dy_sleep_timer ".$sleep_timer);
}

if ($currentObj->{msg} eq "CURRENT-STATE") {
my $power = $currentObj->{"product-state"}->{fpwr};
fhem("setreading ".$device." dy_power ".$power); #OFF, ON

my $fan_auto = $currentObj->{"product-state"}->{auto};
fhem("setreading ".$device." dy_fan_auto ".$fan_auto); #OFF, ON

my $fan_state = $currentObj->{"product-state"}->{fnst};
my $fan = "ON";

if ($fan_state eq "FAN") {
fhem("setreading ".$device." dy_fan_state ".$fan)};

if ($fan_state eq "OFF") {
fhem("setreading ".$device." dy_fan_state ".$fan_state)}; #Running yes:FAN no:OFF





my $fan_speed = $currentObj->{"product-state"}->{fnsp};
my $automatic = ReadingsVal($device,"dy_fan_auto","OFF");
my $write = "AUTO";
#fhem("setreading ".$device." dy_fan_speed ".($fan_speed+0));

if (($fan_speed >= 1) && ($fan_speed <= 10) && ($automatic eq "OFF")) {
fhem("setreading ".$device." dy_fan_speed ".($fan_speed+0))};


if ($automatic eq "ON") {
fhem("setreading ".$device." dy_fan_speed ".$write)};




my $fan_airflow = $currentObj->{"product-state"}->{fdir};
my $airflow_front = "FRONT";
my $airflow_rear = "REAR";

if ($fan_airflow eq "ON") {
fhem("setreading ".$device." dy_fan_airflow ".$airflow_front)};

if ($fan_airflow eq "OFF") {
fhem("setreading ".$device." dy_fan_airflow ".$airflow_rear)};



my $fan_osc = $currentObj->{"product-state"}->{oson};
fhem("setreading ".$device." dy_fan_oszilation ".$fan_osc); #OFF, ON

my $night_mode = $currentObj->{"product-state"}->{nmod};
fhem("setreading ".$device." dy_night_mode ".$night_mode); #OFF, ON

my $standby_monitoring = $currentObj->{"product-state"}->{rhtm};
fhem("setreading ".$device." dy_standby_monitoring ".$standby_monitoring); #OFF, ON


}


}
######################################################
########   
######## Dyson command string composer - eddy242 last edit Sandra Ohmayer (Blackcat)
########         
######################################################


sub dyson_json_compose {
my ($command,$value) = @_;

# das spezielle Format für die Zeit im JSON für den Dyson
my $t = time;
my $date = strftime "%Y-%m-%dT%H:%M:%S", gmtime $t;
$date .= sprintf ".%03dZ", ($t-int($t))*1000; # without rounding

my $commandString = "{\"data\":";

if ($command eq "fpwr") { $commandString .= "{\"fpwr\":\"".$value."\"},\"mode-reason\":\"LAPP\",\"time\":\"".$date."\",\"msg\":\"STATE-SET\""} # Fan-Mode, VALID: OFF, AUTO,
elsif ($command eq "fnsp") { $commandString .= "{\"fnsp\":\"".$value."\"},\"mode-reason\":\"LAPP\",\"time\":\"".$date."\",\"msg\":\"STATE-SET\""}# Fan-Speed, VALID: 1..10
elsif ($command eq "auto") { $commandString .= "{\"auto\":\"".$value."\"},\"mode-reason\":\"LAPP\",\"time\":\"".$date."\",\"msg\":\"STATE-SET\""}# Fan-Speed, VALID: 1..10
elsif ($command eq "qtar") { $commandString .= ",\"data\":{\"qtar\":\"".$value."\"}"} # Quality?
elsif ($command eq "nmod") { $commandString .= ",\"data\":{\"nmod\":\"".$value."\"}"} # nmod?
elsif ($command eq "oson") { $commandString .= "{\"oson\":\"".$value."\"},\"mode-reason\":\"LAPP\",\"time\":\"".$date."\",\"msg\":\"STATE-SET\""} # Oszillation, VALID: OFF, ON
elsif ($command eq "osau") { $commandString .= "{\"osau\":\"".$value."\"},\"mode-reason\":\"LAPP\",\"time\":\"".$date."\",\"msg\":\"STATE-SET\""} # Oszillation_Grad, VALID: OFF, ON
elsif ($command eq "fpwr") { $commandString .= ",\"data\":{\"fpwr\":\"".$value."\"}"} # Power, VALID: OFF, ON
elsif ($command eq "rhtm") { $commandString .= ",\"data\":{\"fmod\":\"FAN\", \"rhtm\":\"".$value."\", }"} # Fan-Mode + rhtm?, VALID (Fan-Mode: OFF, AUTO, FAN) + (rhtm: OFF, ON)
else { $commandString .= ",\"data\":{\"fmod\":\"OFF\"}" }; # notfalls aus

# und noch die Klammer zu
$commandString .= "}";

# Wenn das Kommando Status Request war ist der Commandstring simpel
if ($command eq "sreq") { $commandString = "{\"mode-reason\":\"LAPP\",\"time\":\"".$date."\",\"msg\":\"REQUEST-CURRENT-STATE\"}"};
if ($command eq "ereq") { $commandString = "{\"mode-reason\":\"LAPP\",\"time\":\"".$date."\",\"msg\":\"REQUEST-PRODUCT-ENVIRONMENT-CURRENT-SENSOR-DATA\"}"};
#if ($command eq "sreq") { $commandString = "{\"msg\":\"REQUEST-CURRENT-STATE\",\"time\":\"".$date."\"}"};
#if ($command eq "ereq") { $commandString = "{\"msg\":\"REQUEST-PRODUCT-ENVIRONMENT-CURRENT-SENSOR-DATA\",\"time\":\"".$date."\"}"};

# Log3 (undef, 3, $commandString);
return $commandString;
}


Mit freundlichen Grüßen


Invers

Scheint mit dem TP04 nicht zu funktionieren. Da kommt immer nur disconnected.  Schade.
Pi3B+ mit SSD/ Bullseye | FB7590 AX | 12 x Dect200 | CUL433+868 | SDuino | HM-LAN | 3 x Heizung FHT + FKontakte | KeyMatic + 4 FB | HM Wandtaster 2-fach m. LED | 6 x Türkont. TFK-TI | HM-Bew.-Melder innen | 3 x Smoked. HM-SEC-SD-2

Shadow3561

Mein TP04 läuft super mit FHEM.
Hast du die Anleitung oben befolgt? Passwort und Benutzername gesnifft?
Wenn dann immer ein diconnect kommt liegt es höchstwahrscheinlich an FHEM/MQTT.

Mit freundlichen Grüßen