Problem Update Elec Smart P1

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.

Moderator: leecollings

Post Reply
nepheris
Posts: 4
Joined: Friday 06 November 2015 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Problem Update Elec Smart P1

Post by nepheris »


Hello I have some problem with updating a virtual Smart P1 on Domoticz.
Domoticz is running on as Raspi and i importing data form a Homewizard box via the API of the box. I made a script (see below) that send the following Html request to update Domoticz Smart P1 (Idx 65) via an Html wget. When I launch the script mannually "sudo bash /home/pi/hw/script/hw2domoticz-CompteurElecV2.sh " even 10 times per minute this script is works perfectly
but as soon I am lauching it via the same command in crontab every 15min this virtual sensor get corrupted.
I am updating some temperature , Electric, kWh, and many other domoticz virtual sensor by the same method (script that is periodically lauched by crontab) without problem.
You will find below the Domoticz IDX request to see what the sensor corruption look like & my bash script that should be lauched via crontab every 15min
Can you please help me ?

http://IPDomoticz:PORT/json.htm?type=devices&rid=65
ActTime: 1453701214,
ServerTime: "2016-01-25 06:53:34",
Sunrise: "08:30",
Sunset: "17:33",
result: [
{
AddjMulti: 1,
AddjMulti2: 1,
AddjValue: 0,
AddjValue2: 0,
BatteryLevel: 255,
Counter: "0.000",
CounterDeliv: "0.000",
CounterDelivToday: "0.000 kWh",
CounterToday: "0.000 kWh",
CustomImage: 0,
Data: 1004;0;0;0;240;0",, ==> this one change to "0, ;0;0;0;170;0",
Description: "",
Favorite: 0,
HardwareID: 5,
HardwareName: "Dummy",
HardwareType: "Dummy (Does nothing, use for virtual switches only)",
HardwareTypeVal: 15,
HaveTimeout: false,
ID: "82064",
LastUpdate: "2016-01-25 06:53:04",
Name: "Idx 65 Elec P1 Smart Meter",
Notifications: "false",
PlanID: "0",
PlanIDs: [
0
],[/sub]

Code: Select all

##!/usr/bin/bash
## sudo bash /home/pi/hw/script/hw2domoticz-CompteurElecV2.sh 

ConsokWh=`cat HWsensors| jq ".response.energymeters[0].dayTotal"|tr -d '\n'` # echo $ConsokWh
EDFcompteurhier2359=$(cat EDFcompteur) #echo $EDFcompteurhier2359
EDFcompteurTemp=$(bc <<< "$ConsokWh+$EDFcompteurhier2359") #echo $EDFcompteurTemp
EDFcompteurTempENTIER=$(bc <<< "($EDFcompteurTemp+0.5)/1") #echo $EDFcompteurTempENTIER

IDX="65" IPdomoticz="http://192.XXX.XXX.XX:PORT"
USAGE1=$EDFcompteurTempENTIER 
USAGE2="0"   
CONS=$InstantWatt
RETURN1="0" 
RETURN2="0" 
PROD="0"  # si production courant 
DomoticzElecP1url=$IPdomoticz"/json.htm?type=command&param=udevice&idx="$IDX"&nvalue=0&svalue="$USAGE1";"$USAGE2";"$RETURN1";"$RETURN2";"$CONS";"$PROD
wget -i $DomoticzElecP1url -O /dev/null   # echo $DomoticzElecP1url~
paulvha
Posts: 40
Joined: Friday 29 January 2016 16:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Problem Update Elec Smart P1

Post by paulvha »

I had a look, but this is straight forward. Are you sure that the value EDFcompteurTempENTIER / USAGE1 is correct all the time before updating ? Maybe an echo to append to a tmp_file of DomoticzElecP1url just before wget from debug ? At least we then know what direction to look.
User avatar
erem
Posts: 230
Joined: Tuesday 27 March 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Amsterdam/netherlands
Contact:

Re: Problem Update Elec Smart P1

Post by erem »

not sure if this will help, but the shebang format is #!/usr/bin/bash, not ##!/usr/bin/bash
Regards,

Rob
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest