Why are you trying to get output other than what you’re currently getting? Redirecting to a file is giving you what you want, all you need is to do the above suggestion and then you’re an awk, tail, and grep away from getting the actual number.
i think that writing another py which transports the values to a second file is an option. but i myselve would only use that option if i couldnt get it to work without that.
continously running a second py code to extract the values would use more resources then needed and would give a bigger failurerisk then needed, if it is possible without it.
Josh - You’ve hit the nail on the head. I’ve been over thinking it. Thanks.
I came up with this and it’s working a treat… (I suppose I ought to clear down the log file though somehow at some point in time - it writes every six seconds).
Well, I am still a bit lost and need some assistance.
I’ve created the following script (based on molobrakos tips):
433.py:
#!/usr/bin/env python3
import homeassistant.remote as remote
from subprocess import Popen, PIPE
import json
api = remote.API('127.0.0.1', 'PASSWORD')
with Popen(['rtl_433', '-F', 'json', '-C', 'customary', '-R', '39'], stdout=PIPE, bufsize=1, universal_newlines=True) as p:
for line in p.stdout:
tjson = json.loads(line)
#print(tjson)
temp = "%.1f" % tjson['temperature_F']
humidity = tjson['humidity']
print('temp %s' % temp)
print('humidity %s' % humidity)
# Getting the ID from tjson and matching it up with
# the string name of the sensor in HomeAssistant is
# left as an exercise to the reader
remote.set_state(api, ????? , new_state=temp)
So… now what? How to configure the HA to get the temp and the humidity?
I think HA with create the device in HA automatically if you just feed it data through the API. Then you can customize name, icons etc via the customize-section in your configuration. Alternatively, you can set it to hidden and create a template-sensor in HA that consumes data from it.
(you don’t need the Popen-things, if you instead just start the script with rtl_433 -F json -C customary -R 39 | ./my_script)
Hi guys - just new to HA & I’ve got currentcost. Any pointers re where best to start re trying to get currentcost connected up/working with HA? Existing component? or anyone have Python code I could use?