Posts

Showing posts from 2018

Multiple Broadlink RM mini 3 integration using MQTT

Broadlink now has quite a lot of integration options almost out of the box. If you enable Broadlink IHC, you can directly link it to Alexa by giving the device a unique name. There is a homebridge plug in for homekit integration but I haven't tried or tested this. https://lprhodes.github.io/slate/ I wanted to put the device in domoticz so I can have more control over what can trigger my broadlink. I decided to use broadlink-mqtt for this, which is a fairly easy method to trigger from any source. Setup Instructions for broadlink-mqtt 1. git clone https://github.com/eschava/broadlink-mqtt 2. vi /home/pi/broadlink-mqtt/mqtt.conf 3. Update the mqtt.conf file with the device type set as multiple_lookup device_type = 'multiple_lookup' mqtt_multiple_subprefix_format = '{type}_{mac_nic}/' 4. Start the python script and check that it started and detected all the RM devices. Check the log file to see what the IP / MAC addresses are. DEBUG Connected t...

Installing Raspbian Stretch on a new Pi

My first pi is fully used and has hit production mode where it runs the house and I can't use it as a play toy anymore. It's running Jessie, which is super stable. Guess to move on, I've got a 2nd pi which I've decided to put raspbian stretch and here are some notes of the install because it never really goes as planned. After downloading and running raspi-config to region, etc. apt upgrade failed with hash sum mismatch using the default apt sources.  I tried a few and what worked for me was: deb http://mirror.rise.ph/raspbian/raspbian/ stretch main contrib non-free rpi after apt-get upgrade worked, I went on to install java.  I had some issues as well with  "Error: missing `server' JVM at `/usr/lib/jvm/java-8-openjdk-armhf/jre/lib/arm/server/libjvm.so'."  which was fixed with sudo apt-get purge openjdk-8-jre-headless sudo apt-get install openjdk-8-jre-headless sudo apt-get install openjdk-8-jre Ok, moving on to some software, i prefer a ...

Displaying a common device status

Once everything is merged, the challenge will be to make sure all devices are reported to the correct status. There are 2 main stores of device state in my setup; Domoticz Fibaro Basically we want Domoticz to know the state of the Fibaro devices and also Fibaro to be able to know the state of the domoticz devices. There shouldn't be 2 different master sources of data. As Domoticz seems to be the master controller and other devices, e.g. Philips hue is capable of updating the status in domoticz automatically and homebridge uses the domoticz plugin, I'm going with Domoticz as the master status and everything will just query domoticz for the state. To do this, there need to be a virtual device for each appliance that will be have it's state reported. Domotics support all sorts of virtual device, the more common ones we will use is  Switches Sockets (On/Off) Motion Sensor Contact Sensors Lamps/Dimmer Temperature The full list is located here. https...

Fibaro HCL Virtual Device Slider

How to setup Fibaro home center lite (HCL) slider for virtual devices. As the Fibaro HCL does not support LUA. The question was how to update the number value of the slider to send to the HTTP string. Thanks to this site which is a really good reference https://www.vesternet.com/resources/application-notes/apnt-88/ The 2 use cases here are; Sonos HTTP API Volume To allow for volume control for all Sonos devices, add a virtual device with the IP address for SONOS HTTP API and specify the default port to 5005. Create Slider and put the following text into the string. GET /volume/_sliderValue_ HTTP/1.10x0D0x0A0x0D0x0A Domotiz Virtual Devices GET /json.htm?type=command&param=switchlight&idx=XX&switchcmd=Set%20Level&level=_sliderValue_ HTTP/1.10x0D0x0A0x0D0x0A Replace XX with the device ID.

HomeKit Outdoor Weather and Indoor Temperature

Image
This post adds both outdoor temperature and indoor temperature to Apple Homekit. Outdoor Weather / Temperature Using homebridge-weather https://www.npmjs.com/package/homebridge-weather Add the following weather accessory to the homebridge config.json     "accessories": [     {       "accessory": "Weather",       "apikey": " enter_your_own_key_here ",       "locationByCoordinates": "lat= your_lattitude lon= your_longitude ",       "name": "Weather"     }     ] Indoor Temperature I'm taking indoor temperature from the Fibaro HCL temperature sensor, i.e. Aeotec multi-sensor. Option1: cron/bash file to extract temperature to load into Domoticz temperature device In the earlier post, I created a batch file to extract the temperature via REST API from Fibaro HCL to upload to a domo device. Not the most graceful way to do it, but it old school and works. Option 2: Cre...

Automating Samsung MU6100 Series K

Finally upgraded to a new Samsung 4K TV and  iSamsungTV stopped working. The good thing is that so have most people and there is a new app, samsungctl https://github.com/Ape/samsungctl  which  allows command line interface to the TV using websocket, because everyone needs a to open a terminal window to change a channel. I used this link to install samsungctl https://www.domoticz.com/wiki/Plugins/SamsungTV.html Basically I needed to sudo pip3 install samsungctl sudo pip3 install websocket-client After the installation, I had some error messages, i.e. "AttributeError: 'numpy.ndarray' object has no attribute 'tobytes'", which was solved by; sudo pip3 install numpy --upgrade The new TV can be turned on with WakeOnLAN now. This makes my Broadlink RM3 fairly redundant as the older Samsung wasn't able to turn on hence, I needed the IR blaster before.

Control Sonos outside your home using HomeKit

Applying the same concept as the Aeotec Dimmer for Homekit control, we can also use the Domoticz virtual dimmer to control the Sonos using node-sonos-http-api. Homekit > Domoticz Virtual Dimmer (LUA) > node-sonos-http-api > Sonos I'm starting to derive a shorter version of the LUA script for easier maintenance and using the base On and Off action commands on Virtual Device configuration page. Replace the IP address with the raspberry pi running node-sonos-htttp-api. Virtual Device Name SonosOne_Volume Action On Command:  http://192.168.1.XX:5005/Sonos%20One/play Action Off Command: http://192.168.1.XX:5005/Sonos%20One/pause LUA script /home/pi/domoticz/scripts/lua/script_device_SonosOne_Volume.lua commandArray = {} DEV='SonosOne_Volume' if otherdevices[DEV] == 'Off' then         os.execute('curl "http://192.168.1.XX:5005/Sonos%20One/pause"') else         Level = otherdevices_svalues[DEV]     ...

Extract temperature from Fibaro HCL to Homekit Room

For Apple mobile users who want to know the temperature of a room in Apple home using a temperature sensor from Fibaro HCL Automation Flow: Aeotec light/temp sensor > Fibaro HCL > bash script >; Domoticz virtual device > homebridge/homekit Setup Steps Step 1. Create a temperature virtual device in Domoticz and take note of the device id. Step 2. Create a bash file with the following script, replacing the XX  and user:password fields. #!/bin/bash status=/home/pi/scripts/temperature domo_idx= XX fib_idx= XX curl "http:// user:password@XX.XX.XX.XX /api/panels/temperature?type=devices&method=single&id="$fib_idx > $status temperature=`cat $status |  sed 's/[{}]//g' |  awk -F : '{print $3}' | awk -F , '{print $1}'` curl "http://XX.XX.XX.XX:8080/json.htm?type=command&param=udevice&idx="$domo_idx"&nvalue=0&svalue="$temperature Step 3. Create a cron entry to run this script eve...

Home Automation High Level Components

Image
Maybe to put more context into the previous post of a slow build out of home automation components, here's a big picture integration diagram on how everything works together to date. User Interaction Mobile Apps Voice Commands Cloud Services Integration Components Home Automation Bridges Domoticz MQTT Scripts (Python, Bash, LUA, etc.) Connectivity Methods Z-Wave (Fibaro) Zigabee (Philips Hue) Sonos wireless mesh Wifi and LAN Bluetooth Low Energy (BLE) Infra-red Automation Devices Lights, Smart Dimmers Smart Power plugs Temperature, humidity and light sensors Door sensors Cameras Network speaker system Smart TV Air-Conditioners / Thermostats

Use Homekit to control Fibaro HCL Z-Wave Dimmer

Home Automation Flow Siri > Homebridge > Domoticz (LUA) > Fibaro HCL > Aeotec Nano Dimmer Assume that Homebridge, Domoticz and Fibaro is already setup. The homebridge config.json file should have a room reference to avoid Homekit showing all devices {     "bridge": {         "name": "Homebridge",         "username": "CC:21:3E:E4:DE:33",         "port": 51826,         "pin": "031-45-154"     },     "description": "Configuration file for (e)xtended Domoticz platform.",     "platforms": [         {             "platform": "eDomoticz",             "name": "eDomoticz",             "server": "127.0.0.1",             "port": "8080",             "ssl": 0,      ...

Tuning motion.conf lightswitch on raspberry pi for hue lights

Recap on using an non-recording old CCTV to create a motion sensor using raspberry to trigger hue lights with apple homekit automation. Ok, thats a long way around things. Here's a flow 1. Network Camera > 2. motion (pi) on_event  > 3. virtual motion sensor (domoticz / homekit plugin) > 4. Apple home automation (motion on, no motion off) One of the initial problems was that the light turning off will trigger the motion/light. the solution is to modify the 'lightswitch' parameter, which doesn't have a lot of references to what to set, so it's trial and error as each camera feed are always different.. Noted that I did first change the framerate to 20 prior for better quality. To tune the lightswitch setting, set yourself up around the time the motion light is supposed to come on and follow these 3 steps as a general guideline. 1) Set the event_gap to a small number for testing, e.g. 10 seconds so that you do not need to wait for a long time b...

Network camera as motion sensor for lights

Here's a guide to use an old network cctv feed as a motion sensor for lights. https://motion-project.github.io/ Here's what we need 1. URL for jpg feed from the network camera The URL varies for different brands and models. Example URL: http:// /cgi-bin/net_jpeg.cgi?ch=0  2. Raspberry pi with domoticz (already integrated with lights, e.g. hue)  On the raspberry pi, download Motion $ sudo apt-get motion Modify the /etc/motion/motion.conf file (Refer to the  motion documentation ) I removed the following from the motion.conf create a new thread file for each video source comment out in /etc/motion/motion.conf ; videodevice /dev/video0 ; target_dir /var/lib/motion ; stream_port 8081 I also changed the webcontrol_port to 8000 as 8080 conflicts with the default domoticz port. ;webcontrol_port 8080 webcontrol_port 8000 I added a thread file for each video source thread /etc/motion/camera.conf The following is an exampl...