Installing Domoticz on OpenElec RPi?

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
Humanjo
Posts: 2
Joined: Thursday 19 December 2019 20:25
Target OS: Windows
Domoticz version:
Contact:

Installing Domoticz on OpenElec RPi?

Post by Humanjo »

Hello everyone,,

I have no idea where to put my question - 'Installation' might be correct.

I have a Pi3 running OpenElec. OpenElec is a Kodi release which works great on a Pi, but is pretty closed (root access only, but no apt to install stuff). Oh, disclaimer: my *nix knowledge is quite basic, so I may be mixing things up.mobdro.bio/ luckypatcher.tips/ kodi.bio/

Anyway - I would like to monitor the temperature of the OpenElec machine (preferably via Domoticz which I have already installed on another RPi). My first idea was to install Domoticz on the openelec machine - but I cannot do this (curl and apt are not there).

Does anyone have similar setup? I tried searching but most of the results I get are either about controlling Kodi from Domoticz (via web), or just Kodi plugins to view the Domoticz dashboard within Kodi.
Last edited by Humanjo on Wednesday 29 January 2020 22:28, edited 1 time in total.
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Installing Domoticz on OpenElec RPi?

Post by Egregius »

Run a shell script by cron on your openelec. The script must parse the temperature and sent it to domoticz.
Jojik1
Posts: 16
Joined: Monday 06 January 2020 23:57
Target OS: -
Domoticz version:
Contact:

Re: Installing Domoticz on OpenElec RPi?

Post by Jojik1 »

User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Installing Domoticz on OpenElec RPi?

Post by FireWizard »

Hi

Humanjo wrote:
Oh, disclaimer: my *nix knowledge is quite basic
and Egregius wrote:
Run a shell script by cron on your openelec. The script must parse the temperature and sent it to domoticz.
I do not believe that this combination will result in a working script.

Therefore:

Step 1.

Create a virtual Temperature sensor.
- In Domoticz in "Setup" > "Hardware" > Create Dummy (Does nothing, use for virtual switches only).
- Click "Create Virtual Sensors".
- Create a "Temperature sensor". It will appear in the "Temperature" tab.
- Goto "Setup" > "Devices" and look up the newly created "Temperature" device and note down its Idx number. You will need that later.

Step 2

SSH into your OpenElec Raspberry Pi (By default the user is root and the password is openelec).

Code: Select all

$ ssh -l root <IP Address of OpenElec>
Create a script or copy the script to your OpenElec Pi, with the following contents:

I called the script "temp2domoticz.py" and make it executable (chmod 700 temp2domoticz.py)

Code: Select all

#!/usr/bin/python
import subprocess
import time
import os
import urllib2

serverIP = "192.168.10.50:8080"
deviceId = 282

currentTemp = subprocess.check_output(["/usr/bin/vcgencmd","measure_temp"])
currentTemp = float(currentTemp.split("=")[1][:-3])
urllib2.urlopen("http://" + serverIP + "/json.htm?type=command&param=udevice&idx=" + str(deviceId) + "&nvalue=0&svalue=" + str(currentTemp))
Replace after serverIP = "192.168.10.50" the IP address with the IP address of your Domoticz server.
and replace deviceId =282 with the Idx, you just noted down.

A problem, you may encounter, is that "subprocess" and/or "time" and/or "os" and/or "urllib2" are not installed.

As I do not have OpenElec installed on a Raspberry Pi, I cannot test it. Remember OpenElec and also LibreElec are Just enough OS for Kodi.

Step 3.

Create the cronjob
Give the following command:

Code: Select all

crontab -e
and insert the following line:

Code: Select all

*/5 * * * * python /storage/temp2domoticz.py
if you have the script installed in the /storage directory, this will give you an update every 5 minutes.

Regards
Last edited by FireWizard on Monday 27 January 2020 17:53, edited 1 time in total.
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Installing Domoticz on OpenElec RPi?

Post by Egregius »

Why would a shell script work? You're using a python script to execute shell commands...

Something simple like this should do:

Code: Select all

#!/bin/bash
temp=$(vcgencmd measure_temp | grep -o '[0-9]*\.[0-9]*')
curl -s "http://192.168.2.3:8080/json.htm?type=command&param=udevice&idx=2007&nvalue=0&svalue=$temp"
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Installing Domoticz on OpenElec RPi?

Post by FireWizard »

@ Egregius,

You said:
Why would a shell script work?
You probably mean: Why would a shell script not work?

I agree with you, that a shell script will work. I had this Python script "on stock", which worked for me for more than a year, until I changed my setup.

What I wanted to say was that, if Humanjo says "Oh, disclaimer: my *nix knowledge is quite basic.", I do not expect that it is easy for him to create and run a shell script by cron on his openelec. The script must parse the temperature and sent it to domoticz. For an experienced user, writing such a script is not difficult, but for a basic user, it might be quite complex. But maybe I'm wrong.

Nevertheless, it is another way of sending the Temperature to Domoticz and maybe the only way of doing it on OpenElec, as for Python, we might miss some components, as I said. I realized that, after I had posted the Python solution, that a shell script would have been better.
At least, it triggered you to publish this shell script. :D

Regards
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Installing Domoticz on OpenElec RPi?

Post by Egregius »

Yes, I had a typo indeed. I meant "not working"
And yes, because of this I quickly created that little script ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest