if all fails, a logreader device or a shellsensor could help
-
json to device
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
Do I have to install some additional software for this?
If i do this
curl -X GET --silent --user "USER:PASSWD" -s http://192.168.178.20/api/variables/CV_waterdruk | json variable.value
I get this:
-bash: json: opdracht niet gevonden
(whitch means json: command not found)Installed jsontool, but to no avail…
-
sudo npm install json
EDIT:
Sorry. should be.cd ~ npm install json sudo npm link
-
Thank you! That’s indeed what did the trick!
-
@wutu I Know this is an old post, but I cannot seem to find out what you mean. I get an mqtt topic from my tv that gives me the followin payload in Json form. How can I get only certain values to a variable of mqttsensor? I would like to get the channelNumber and the channelName
{ "val": "8", "lgtv": { "subscribed": true, "channelId": "3_33_8_8_2100_19442_1536", "signalChannelId": "2100_19442_1536", "channelModeId": 1, "channelModeName": "Cable", "channelTypeId": 4, "channelTypeName": "Cable Digital TV", "channelNumber": "8", "channelName": "Veronica HD / Disney XD", "physicalNumber": 33, "isSkipped": false, "isLocked": false, "isDescrambled": false, "isScrambled": true, "isFineTuned": false, "isInvisible": false, "isHEVCChannel": false, "favoriteGroup": null, "hybridtvType": "HBBTV", "dualChannel": { "dualChannelId": null, "dualChannelTypeId": null, "dualChannelTypeName": null, "dualChannelNumber": null } } }
-
Hey @JahFyahh
Uselgtv.channelName
as a name for attribute.
More info: https://www.npmjs.com/package/flat and https://forum.pimatic.org/topic/1865/kodi-s-and-mqtt.Pimatic = Smart Home
-
@wutu Thank you for your reply. I already figured that by using a python script to get the attribute from the payload and curl it to an pimatic variable. but is there a way to make pimatic retreive the attributes payload without invloving an external python script?
-
@wutu Never mind, I overlooked somethng in the link and found out how to do it. Thank you.
-
@JahFyahh can you explain how?
-
@temp Using the link: https://forum.pimatic.org/topic/1865/kodi-s-and-mqtt. I realised that lgtv.channelNumber has to be the name of an mqttsensor attribute. (I was overthinking it)
Using GUI
- Create a mqttsensor, name it as you please.
- Add an attribute
- Enter “lgtv.channelNumber” as Name (Attribute name)
I also use the python version, because I wanted to add an kodi thumbnail to an iframe. But the kodi2mqtt changes ASCII encoding in the url in the attribute. So I created an empty iFrame called kodi-thumb and use a rule to load the iframe url with an variable which is populated with the python script:
import paho.mqtt.subscribe as subscribe
import json
import ospimatic_server = '’
pimatic_user = '’
pimatic_pass = ‘**************’pim_user_pass = pimatic_user + ‘:’ + pimatic_pass
curl_prefix = 'curl --silent --insecure -X PATCH --header “Content-Type:application/json” --data '{“type”: “value”, “valueOrExpression”: "'
pim_server_url = pimatic_server + ‘/api/variables/kodithumb’def on_message_print(client, userdata, message):
#print("%s %s" % (message.topic, message.payload))
obj = json.loads(message.payload)
#print “Value : %s” % data[‘val’]
value = obj[‘kodi_details’][‘thumbnail’]
value = value.replace(“image://”, “”)
value = value.replace("/", “”)
value = value.replace("%2f", “/”)
value = value.replace("%3a", “:”)
os.system(curl_prefix + str(value) + ‘"}’ --user “’ + pim_user_pass + '” ’ + pim_server_url)subscribe.callback(on_message_print, “hombmc/status/title”, hostname=“172.0.0.1”)
The Rule:
Kodi State of customkodi5 is equal to “play” for 1 minutes then load kodi-thumb with “$kodithumb”If someone knows a cleaner way to get this done within pimatic without external scripts I would love to know.