-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi there,
I just released my first berry driver -- for victron controllers.
The code is here:
https://github.com/3ricj/VictronTasmota
There was quite a bit I had to determine about berry through raw experimentation because it wasn't documented anywhere. Specifically, syntax around specific operations with lists, how to check for a value on a list without causing an exception, how to interact with json_append and web_sensor secret built in functions, and lots of other random things. I still don't know wny json_append calls happen at a rate faster than it sends json.
Also, there is a pretty good json library in berry (import json), but most examples use basic string concat like it's 1997. Of course, because it's appended json, you have to muck with the value name in order to make valid json come out the other end. here's how to do that:
`
# Stuff a bunch of stuff into a list in different formats.
self.sensorname = "mysensor"
self.jsonstring["Volts"] = real("12.123")
self.jsonstring["Model"] = "testing 5000"
self.jsonstring["BuildVersion"] = 4
# assemble into a valid json string
tasmota.response_append(","" + self.sensorname + "":" + json.dump(self.jsonstring))
`
I'm not sure a full driver implementation should be copied into the playground -- I'll let whoever maintains this figure this out, but as I had to spend so much time figuring out under-documented features, it might be helpful to others.
Best,
-3ric