Domoticz version from .bashrc

All kinds of 'OS' scripts
Post Reply
User avatar
htilburgs
Posts: 509
Joined: Tuesday 03 November 2015 12:01
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Domoticz version from .bashrc

Post by htilburgs » Thursday 01 February 2018 0:42

I'm using the following command to determine the version of Domoticz in my /home/pi/.bashrc script:

Code: Select all

curl -s -X GET "http://127.0.0.1:8088/json.htm?type=command&param=getversion" | /bin/grep "version :" | awk {'print $3'} | /usr/bin/cut -d '"' -f 2 | /usr/bin/cut -d '"' -f 1
The result is:

Code: Select all

2.4.1
3.8872
The reason is there is twice the word version

Code: Select all

{
   "DomoticzUpdateURL" : "http://www.domoticz.com/download.php?channel=beta&type=release&system=linux&machine=armv7l",
   "HaveUpdate" : false,
   "Revision" : 8872,
   "SystemName" : "linux",
   "build_time" : "2018-01-29 16:59:49",
   "dzvents_version" : "2.4.1",
   "hash" : "fc97f529",
   "status" : "OK",
   "title" : "GetVersion",
   "version" : "3.8872"
}
Now my knowledge stops... How can I solve this, so I see only the Domoticz version, in this case 3.8872 ??
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3

Damsee
Posts: 16
Joined: Thursday 20 April 2017 1:17
Target OS: Raspberry Pi
Domoticz version: 4.9700
Location: France
Contact:

Re: Domoticz version from .bashrc

Post by Damsee » Thursday 01 February 2018 0:48

You can add another grep command to remove the dzvents version.
Add it before your 1sr grep : grep -v dzvents

Hope that helps ;-)
RPI3 Raspbian Stretch + Domoticz v4.9700 stable + RFXtrx433E + Z-Stick Gen5 + Amazon Echo (controlicz)
x5 THGN810 / x5 ZMNHJD1 / x2 Flood sensor FGFS101 / x1 Smoke sensor FGSD002
x1 ZMNHAD1 / x2 FGS213 / x3 Wallplug FGWPE/F / NodOn Soft remote CRC-3-6-0

User avatar
htilburgs
Posts: 509
Joined: Tuesday 03 November 2015 12:01
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by htilburgs » Thursday 01 February 2018 0:59

Yes! That did the trick. Thnx.
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3

User avatar
htilburgs
Posts: 509
Joined: Tuesday 03 November 2015 12:01
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by htilburgs » Thursday 01 February 2018 1:05

For who is interested: Edit the file /home/pi/.bashrc and put at the end the following code:

Code: Select all

echo "$(tput setaf 2)
/////    ////    /     /    ////   ///////   /////  //////   //////
/    /  /    /   //   //   /    /     /        |    /            /
/    /  /    /   / / / /   /    /     /        |    /           /
/    /  /    /   /  /  /   /    /     /        |    /          /
/    /  /    /   /     /   /    /     /        |    /         /
/////    ////    /     /    ////      /      /////  //////   //////

`date +"%A, %e %B %Y, %r"`

Hardware Model............: `(tr -d '\0' </proc/device-tree/model)`
OS Version................: `/usr/bin/lsb_release -s -d  | grep Raspbian | awk {'print $1,$3,$4'}`
Kernel....................: `uname -srmo`

Domoticz Version..........: `curl -s -X GET "http://127.0.0.1:8088/json.htm?type=command&param=getversion" | /bin/grep -v dzvents | /bin/grep "version" | awk {'print $3'} | /usr/bin/cut -d '"' -f 2 | /usr/bin/cut -d '"' -f 1`
Domoticz Release..........: `curl -s -X GET "http://127.0.0.1:8088/json.htm?type=command&param=getversion" |grep -Po '(?<=channel=)[^&]*'`
Domoticz Servicebuild.....: `curl -s -X GET "http://127.0.0.1:8088/json.htm?type=command&param=getversion" | /bin/grep "build_time" | awk {'print $3,$4'} | /usr/bin/cut -d '"' -f 2 | /usr/bin/cut -d '"' -f 1`
$(tput setaf 1)
Uptime....................:  `exec --  uptime -p`
Memory....................:  `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
Running Processes.........:  `ps ax | wc -l | tr -d " "`
IP Addresses..............:  `sudo hostname -I`
Free Disk Space SD........:  `df -Pk | grep -E '/root' | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`k on /root
CPU Temperature...........:  `exec -- /opt/vc/bin/vcgencmd measure_temp | cut -c "6-9"` C
$(tput setaf 2)
Domoticz Service status...: `sudo service domoticz status | grep Active | cut -c "11-54"`
"
The result:
Schermafbeelding 2018-02-01 om 00.04.33.png
Schermafbeelding 2018-02-01 om 00.04.33.png (52.08 KiB) Viewed 901 times
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3

User avatar
waaren
Posts: 719
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by waaren » Thursday 01 February 2018 1:39

Nice overview of your system. If you want to get the version of domoticz even if not active at the moment:

"path to domoticz dir"/domoticz --help | grep Giz | awk {'print $4'}
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

User avatar
Siewert308SW
Posts: 607
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Domoticz version from .bashrc

Post by Siewert308SW » Thursday 01 February 2018 7:57

Or you could do it a bit cleaner with a double grep.
You could grep the entire piece: '"version" :'

So it becomes:
curl -s -X GET "http://127.0.0.1:8080/json.htm?type=com ... getversion" | /bin/grep '"version" :' | awk {'print $3'} | /usr/bin/cut -d '"' -f 2 | /usr/bin/cut -d '"' -f 1
Setup:
- RPi3 - PIco HV3.0A / Domo Beta 3.9XXX / RFXtrx433E / Aeotec Gen5
- RPi3 - PIco HV3.0A / PiHole / PiVPN / NAS / Print Server
- Youless Elec&Gas
- FI9803P Cams
- KD101 detectors
- Zwave & KaKu

MyDomoticz scripts: @GitHub
PIco UPS Toolkit: @GitHub

User avatar
htilburgs
Posts: 509
Joined: Tuesday 03 November 2015 12:01
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by htilburgs » Thursday 01 February 2018 9:07

Siewert308SW wrote:
Thursday 01 February 2018 7:57
Or you could do it a bit cleaner with a double grep.
You could grep the entire piece: '"version" :'

So it becomes:
curl -s -X GET "http://127.0.0.1:8080/json.htm?type=com ... getversion" | /bin/grep '"version" :' | awk {'print $3'} | /usr/bin/cut -d '"' -f 2 | /usr/bin/cut -d '"' -f 1
Thnx for this 'cleaner' version. I'm learning by the day.
Implemented, tested and it works...!
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3

User avatar
sincze
Posts: 927
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi
Domoticz version: 3.8875
Location: Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by sincze » Sunday 15 April 2018 17:45

htilburgs wrote:
Thursday 01 February 2018 9:07
Siewert308SW wrote:
Thursday 01 February 2018 7:57
Or you could do it a bit cleaner with a double grep.
You could grep the entire piece: '"version" :'

So it becomes:
curl -s -X GET "http://127.0.0.1:8080/json.htm?type=com ... getversion" | /bin/grep '"version" :' | awk {'print $3'} | /usr/bin/cut -d '"' -f 2 | /usr/bin/cut -d '"' -f 1
Thnx for this 'cleaner' version. I'm learning by the day.
Implemented, tested and it works...!

Code: Select all

{
   "DomoticzUpdateURL" : "http://www.domoticz.com/download.php?channel=beta&type=release&system=linux&machine=armv7l",
   "HaveUpdate" : true,
   "Revision" : 9227,
   "SystemName" : "linux",
   "build_time" : "2018-03-30 12:51:25",
   "dzvents_version" : "2.4.1",
   "hash" : "617c5526",
   "python_version" : "3.5.3 (default, Jan 19 2017, 14:11:04) \n[GCC 6.3.0 20170124]",
   "status" : "OK",
   "title" : "GetVersion",
   "version" : "3.9138"
}
Thanks, you just saved my day. :D I use this to make a backup of my domoticz and store the value of the current version in the filename. domoticz-server-v3.9138-15-04-2018-17.43.32.tar
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest