Fhem Deutsch

0 views
Skip to first unread message

Kerby Kolpack

unread,
Aug 5, 2024, 1:27:06 AM8/5/24
to luopotmonyl
Zigbeeis a specification for a suite of high-level communication protocols used to create personal area networks with small, low-power digital radios, such as for home automation, medical device data collection, and other low-power low-bandwidth needs, designed for small scale projects which need wireless connection. Hence, Zigbee is a low-power, low data rate, and close proximity wireless ad hoc network.

The Zigbee2MQTT bridge enables you to use selected supported ZigBee devices without the otherwise mandatory Hub and Vendor Cloud connection. Among the devices that you can control are smart (ZigBee) light bulbs from Belkin, IKEA, OSRAM and Philips as well as smart sensors from SmartThings and Xiaomi.


The ZigBee bridge consists of a ZigBee Sniffer Module and a controlling software written in Node.js. It bridges events and allows you to control your Zigbee devices via MQTT. In this way you can integrate your Zigbee devices with whatever smart home infrastructure you are using.


After flashing your CC2531 USB sniffer with CC2531ZNP-Prod.hex firmware we can remove the CC Debugger and connecting cable and plug the Sniffer into our Linux computer you can use a Raspberry Pi 3 with Raspbian Stretch Lite, but will work on any Linux machine.


I am going to use a local Mosquitto MQTT server running on a INSTAR Full HD Camera on 192.168.2.115. Alternatively, you can install a local Mosquitto Server on your Raspberry Pi and add it via server: 'mqtt://localhost' in the config file.


I am not sure if Zigbee2MQTT offer TLS support - I will have to look into that. Also, I deactivated the user authentication on my MQTT server for now to have an easier time debugging - user name and password have to be added here before reactivating it.


You can see that the service is running, connected to the local MQTT server and published a message to zigbee2mqtt/bridge/state with the payload online. We can use the program MQTT Explorer to verify that the message was received by our Mosquitto server:


The number of devices that you can use with the zigbee2mqtt bridge is steadily growing (there are alternative pairing instructions available here). In this tutorial we are going to add 3 XiaoMi Mi Home sensors - a Temperature & Humidity Sensor, a Wireless Switch and a Home Occupancy Sensor.


IMPORTANT: Before you start, make sure that permit_join: true is set in your configuration.yaml. Otherwise new devices cannot join the network! Also verify that the ZigBee2MQTT Bridge is running.


We first start with the Temperature & Humidity Sensor that has a pairing button on its side. Press the button for about 5 seconds - the blue LED will start to blink: in my case it started to blink slowly in 3-time sequences. After a few seconds the blinking sped up and stopped and the device was paired with the ZigBee Bridge.


All paired devices will be listed at the bottom of the configuration file - just change the friendly_name to something human-readable. Remember that this will also change the MQTT topic the Zigbee bridge is using to publish the sensor readouts:


You can find an instruction that you need to press and hold the pairing button for 5 seconds (until the blue LED starts flashing), then release and keep pressing the button repeatedly (1s interval) afterwards - which feels a little bit counter-intuitive. But it actually works. Checking the log file shows that a Occupancy Sensor with the ID 0x00158d00020b3dff was connected:


Note that the Occupancy Sensor sends a true or false payload depending on if motion was detected or not. The Temperature & Humidity Sensor just sends number values for temperature and humidity. And the Wireless Button sends click events and can discern between single, double, triple, quadruple and long / long_release clicks.


This should install and start your MariaDB instance. We can now continue to configure our database. By default the database can only be accessed by localhost - this might be perfectly fine (and is the secure option), but if you want to be able to access data on your Raspberry Pi from different computers we have to comment out the line bind-address = 127.0.0.1 inside:


When successful, this will have created a database with the name fhem and two tables called current and history (For me the new table did not show up in SQLElecton right away after it was created. I disconnected, edited the database entry - see 2 screenshots up - and set the Initial Database to fhem. After reconnecting everything looked as it should):


And don't forget to the set the DBLogType to Current/History (see bottom of the screenshot above). We can verify that the logging has started by querying the content of our Current Table:


In my case only the temperature/humidity sensor and motion detector generates data that I want to use in later projects - the rest should be excluded. For this, we can go back to our DBLogging device in FHEM - :8083/fhem?detail=DBLogging and change the default DbLogSelectionMode to Exclude/Include:


The regular expression .* includes everything and so nothing is logged anymore. Note: If you already have many devices included, simply use the following command to set this attribute for all your devices: attr .* DbLogExclude .*. To automate this for future devices use the following notify function:


I now have a reading for the temperature inside my office - and might add a few more temperature sensors in the future. But it would be interesting to see how well the temperatures I measure fit the temperatures I can get from an online weather services like DarkSky.net. Click the link and select your city - you will find the coordinates that DarkSky assigns to your location inside the URL - in case of Shenzhen, China this is 22.5446,114.0545:


Once we know our ID we can start using the integrated weather module in FHEM to query the corresponding information for our location. Just make sure that your Raspberry Pi has the following Perl libraries installed so FHEM knows how to handle the API's JSON response (shutdown restart FHEM after the installation was successful):


We now set up the Zigbee Bridge, connected Zigbee sensors and made sure that the messages are send to our Mosquitto MQTT server. We also found out the topics that our bridge uses for each sensors to publish its messages - zigbee2mqtt/motion_pir_sensor, zigbee2mqtt/temp_hum_sensor and zigbee2mqtt/smart_button - and what kind of payload to expect.


Connect all 3 of them to a Debug Node and deploy the flow. Click the button, warm up the temp sensor and trigger the motion detection - the MQTT messages will show up in the debug pane in Node-RED:


In the following sequence we are using the input for the wireless button to switch Alarm Areas on our cameras - we already used the same sequence for the Amazon Alexa Integration (the complete flow can be found in the Home Assistant Tutorial):


Next follows a Change Node that changes the Message Payload to the value of Click - as we learnt above, this value can either be single, double, triple, quadruple, long or release:


After that follows a String Node (this node type has to be installed manually - it is called node-red-contrib-string) that searches for the payload single or double and replaces them with something that we need to trigger the Flow below - in this case we need a JSON expression that either sets a value to on or off: "val" : "on" / "val" : "off":


And last but not least we add a Link Node to plug it in to all 4 sequences for the for the 4 alarm areas. Now every time we single-click the Wireless Button all areas are activated. A double-click deactivates them:


We attached a Debug Node to the MQTT input to visualize the input given by the Wireless Button - Note that only the single and double click trigger the Alarm Area Sequences - the rest of the input options can be used for other functions.


FHEM is a software, written in perl, which enables you to manage (eg. EVL) home automation devices over a Webinterface, with the Help of a radio transmitting USB Stick (CUL/CUN). As an alternative to USB Transmitters/Receivers LAN-devices can be used (CUNO/HM-CFG-LAN).I installed it on a Buffalo WZR-HP-AG300H, which has plenty of memory and storage. You might have to install it on an external usb storage or make a swapfile on the usb drive.


Load and install fhem.Replace the Version in the wget command, if you want to try another fhem Version.Unzip the archive.Copy the fhem.pl to /usr/sbin and the Rest to /usr/lib/fhem.The default config file that comes with the archive is best placed in /etc/config/fhem/fhem.cfg.At last we create a log directory for fhem in /var/log/fhem. Please bear in mind that /var/log is reset upon every reboot. Thus fhem will complain about missing log-files. This can be resolved by changing the log-path to something else for example external storage /mnt/sda1.


Now you can use the commandline, but you've got no Webinterface. As perl brings it's own webserver you just have toplace your preferred Webinterface in the folder /usr/lib/fhem/FHEMI got my 01_FHEMWEB.pm via ubuntu repositories (apt-get install fhem) from where it installs to /usr/share/fhem/FHEM'')


Ich habe festgestellt, dass es kein einfaches Tutorial auf deutsch gibt, wie man mal eben Fhem und Deconz im Docker Container unter Unraid laufen lassen kann. Daher dachte ich, ich mache das mal schnell mit ein paar Bildern und sehr leicht verstndlich, in der Hoffnung, dass es jemandem bei Zeiten hilft.


Fhem im Dockercontainer:

Fr Fhem gibt es mittlerweile offizielle Container, die regelmig gepflegt werden, daher bietet es sich an, diese zu nutzen. Um Fhem als Container auf einem unraid System laufen lassen zu knnen, musst du Dich auf der Weboberflche deines unraid Systems anmelden.

Wenn Du USB Gateways oder Culs benutzt, wie z.b. einen 433MHz Cul oder einen Conbee Stick fr Zigbee, musst diese natrlich vorher einstecken. Es empfielt sich allerdings, nicht alle Sticks aufeinmal einzustecken, sondern die Sticks nacheinander. Also erst einen Stick einstecken, diesen dann einrichten/konfigurieren, dann den nchsten Stick und so weiter. Diese vorgehensweise macht es leichter, den jeweiligen Stick zu identifizieren und es kann, wie in meinem Fall, zu Problemen kommen, wenn man alle Sticks aufeinmal steckt.

3a8082e126
Reply all
Reply to author
Forward
0 new messages