Domoticz version from .bashrc

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
User avatar
htilburgs
Posts: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Domoticz version from .bashrc

Post by htilburgs »

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: 58
Joined: Thursday 20 April 2017 1:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Domoticz version from .bashrc

Post by Damsee »

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 Buster + Domoticz v2020.1 stable + RFXtrx433E + Z-Stick Gen5 + Amazon Echo (alexicz)
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: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by htilburgs »

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: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by htilburgs »

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 2100 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: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by waaren »

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'}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Siewert308SW
Posts: 290
Joined: Monday 29 December 2014 15:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by Siewert308SW »

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:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
User avatar
htilburgs
Posts: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz version from .bashrc

Post by htilburgs »

Siewert308SW wrote: Thursday 01 February 2018 6: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: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Domoticz version from .bashrc

Post by sincze »

htilburgs wrote: Thursday 01 February 2018 8:07
Siewert308SW wrote: Thursday 01 February 2018 6: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
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest