Beste,
ik heb sinds een tijdje op een hyperv machine een virtuele windows 10 geinstalleerd, met Domoticz erop. hoe alles binnen Domoticz werkt ben ik nog aan het uitvogelen. omdat ik over een Plugwise Stretch 3.0 beschik zou ik graag het script wat op internet voorkomt willen implementeren. zo langzamerhand heb je namelijk een appje voor dit en een appje voor dat. ik denk dat jullie dit probleem ook wel kennen.
ik lees op internet echter zoveel verschillende verhalen over het toepassen van een script onder windows, dat ik door de bomen het bos niet meer zie. de ene zegt; je moet het onder het script mapje zetten in C:\Program Files (x86)\Domoticz\scripts de ander zegt het moet in je Programdata map. Dan is er nog onduidelijkheid over het type bestand in de map. de ene zegt; je moet alleen de Domoticz installer gebruiken, de ander zegt dat je voor scripts een andere versie van Python moet gebruiken. arg!
omdat ik graag mijn camera's (ip) en mijn stretch wil plaatsen in 1 soort app ben ik dus op zoek naar een oplossing. gezien stroomverbruik etc. zou ik alles het liefste op de hyperv machine willen doen. hier draaien 24/7 servers op, dus die Domoticz server kan hier nog wel bij.
ik heb geprobeerd; linux Debian en Ubuntu met de installer van Domoticz.
ik heb geprobeerd; Raspbian stretch, maar liep stuk op bepaalde certificaten (erg mooi vanwege low specs)
ik heb geprobeerd; windows 10 met de Domoticz software, de webserver e.d draaien als een trein! echter die scripts toevoegen wil niet
ik beschik niet over een RFXCOM, zou ik dat wel moeten? mocht dat zo zijn ga ik het overwegen en moet ik van hyperv afstappen, maar het lijkt me wenselijk eerst die scripts werken te krijgen voor ik ga investeren.
Zouden jullie me op weg willen helpen?
het script van de Stretch (3.0)
#!/bin/bash
#Parameters section
#Folders and files
scriptfolder=/home/pi/domoticz/scripts/
#The tempFile should preferably be on a ramdisk to avoid SD card wear
tempFile=/var/tmp/ram0/tempPlugwiseRead
#Plugwise Stretch parameters
stretchIP=<ip>
stretchPassword=<password>
#Domoticz Parameters
domoticzIp=192.168.2.40
domoticzPort=8080
#domoticzUser=[username for domoticz]
#domoticzPassword=[password for domoticz]
#Devices
MACPanelenGarage=000D6F000xxxxxxx
MACPanelenDak=000D6F000xxxxxxx
PanelenGarageDakID=64
#end of parameters section, no further customization should be needed from here
# Read sensor data "produced" from the plugwise zigbee network trough the stretch API.
curl -s --user stretch:$stretchPassword $stretchIP"/core/modules" | \
xmlstarlet sel -I \
-t -m "/modules/module" \
-v "services/electricity_point_meter/measurement[@directionality='produced']" -o ";" \
-v "services/electricity_interval_meter/measurement[@directionality='produced']" -o " " \
-v "protocols/network_router/mac_address" \
-v "protocols/network_coordinator/mac_address" -n \
| sed 's/\;\ //g' | sed 's/\ \ /\ /g' | sed 's/^ *//g' | sed 's/\;\;0\ //g' | sed '/^$/d' | awk ' { t = $1; $1 = $2; $2 = t; print; } ' > $tempFile.sensorsP
# now do some substitution for the "produced" data to match the plugwise network with the domoticz device ID's.
# the translate.sensors file contains the MAC addresses of the sensors and corresponding domoticz ID's.
# the result is a url for the domoticz json API that is stored in the result variable
resultP=`awk '
FNR==NR{a[$1]=$2;next}
$1 in a{print "/json.htm?type=command¶m=udevice&idx=" a[$1] "&nvalue=0&svalue=" $2 $3 }
' $scriptfolder"/translate.sensorsP" $tempFile.sensorsP `
#for debugging
#for i in $resultP
#do
# echo $resultP[i]
#done
# Storing values, the URL is sent to the domoticz API
for i in $resultP
do
echo `curl -s $domoticzIp:$domoticzPort$i`
done
# finally add the values of the two sensors reading the "produced" values (I use two sensors to get my Solarpanel production) and display total value in a dummy sensor
filename="$tempFile.sensorsP"
while read -r line
do
# echo "MACadres read from file -:$line"
if [[ $line = *$MACPanelenGarage* ]]
then
# echo "found MACPanelenGarage in line"
# remove spaces
bothvalues=${line##* }
#split the values separated bij a ';'
ARRbothvalues1=( $( echo "$bothvalues" | sed -e 's/;/\n/g' ) )
# echo "${ARRbothvalues1[@]}"
# echo "${ARRbothvalues1[0]}"
# echo "${ARRbothvalues1[1]}"
fi
if [[ $line = *$MACPanelenDak* ]]
then
# echo "found MACPanelenDak in line"
# remove spaces
bothvalues=${line##* }
#split the values separated bij a ';'
ARRbothvalues2=( $( echo "$bothvalues" | sed -e 's/;/\n/g' ) )
# echo "${ARRbothvalues2[@]}"
# echo "${ARRbothvalues2[0]}"
# echo "${ARRbothvalues2[1]}"
fi
done < "$filename"
# add the corresponding values and store them, convert the "reals" with BC
result1=$(echo ${ARRbothvalues1[0]} + ${ARRbothvalues2[0]} | bc)
result2=$(echo ${ARRbothvalues1[1]} + ${ARRbothvalues2[1]} | bc)
# finaly update the dummy sensor by sending the URL to the domoticz API
curl -s $domoticzIp":"$domoticzPort"/json.htm?type=command¶m=udevice&idx="$PanelenGarageDakID"&nvalue=0&svalue="${result1}";"${result2}
#Now read the plugwise circle switch status trough the stretch API, write the status to the switches listed in the switches file
curl -s --user stretch:$stretchPassword $stretchIP"/core/modules" | \
xmlstarlet sel -I \
-t -m "/modules/module" \
-v "concat(protocols/network_coordinator/mac_address,services/relay)" \
-v "concat(protocols/network_router/mac_address,services/relay)" \
| sed 's/\t//g' | sed 's/\n//g' | tr '\n' ' ' | sed 's/\ 0/\n0/g' | sed 's/on/1/g' | sed 's/off/0/g' > $tempFile.switches
# again, do matching, now against the translate.switches file
result=`awk '
FNR==NR{a[$1]=$2;next}
$1 in a{print "/json.htm?type=command¶m=udevice&idx=" a[$1] "&nvalue=" $2 }
' $scriptfolder"/translate.switches" $tempFile.switches `
# Storing values
for i in $result
do
echo `curl -s $domoticzIp:$domoticzPort$i`
done
|