ThomDietrich/miflora-mqtt-daemon

flores_to_openhab_items

Closed this issue · 10 comments

Arch Linux RaspPi0W here. Had to delete line 237, got an UnicodeEncodeError, ascii something after fetching ble data. Guess its because no openhab is running here? Im no pro so dono if this is relevant. Wanted to integrate this into node-red and your projekt seemed to be the best way. Cheers

Hey @dingausmwald 👋

The openHAB items generation is just a small function that generates text - no actual interaction with openHAB. The project is perfectly fine to be used with node-red.

The function is currently called unconditionally but I was going to add command line arguments and bind the function to one so a user can have these items generated explicitly.

I'm still riddled by the actual error you are seeing. The function is basically building a big string from existing data. I'd bet the error is linked to your configuration. Are there any non-ASCII characters in your flower names? Which line in this function throws the error? It would be great if you could help track down the error!

Btw. I know that node-red supports import and export of flows. Is there anything the script could generate for node-red to be imported for ease of use?

No. Alle 6 Sensors called Sensor1 -6 in the config.ini. Maybe its because i used a class4 32gb sd Card and somewhere something went wrong on installation? Everybody is writing a class 10 card is a must. Had to hack my bluetooth like this https://loads.pickle.me.uk/2017/03/18/bluetooth-on-archlinux-on-the-pi-zero-w/

(seems like bt is not properly workin on the 0W, but havent even tried it the regular way). Im fairly new to this and feeling like hacking myself to heaven somehow, everyday, 24/7, since weeks. But i have progress, thanks to you.

Okay then there must be another issue. Would be great to know where exactly the exception is raised.

I'll leave the issue open till we found a solution.

In the meantime I've implemented the command line arguments thingy. I'm currently testing and will push it this evening. Stay tuned.

If you are having these many issues, why arch linux? Why not Raspbian (or openhabian if you intend to use openHAB)?

I'd still be interested in the node-red question.

Im willing to help
unqouotet the line again, here are the last lines of my log with the error:

[2017-08-27 17:36:36] Initial connection to Mi Flora sensor "Sensor6" (C4:7C:8D:65:61:06) successful

[2017-08-27 17:36:36] Announcing Mi Flora devices to MQTT broker for auto-discovery ...

[2017-08-27 17:36:37] Generating openHAB "miflora.items" file ...
Traceback (most recent call last):
File "opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py", line 237, in
flores_to_openhab_items(flores, reporting_mode)
File "opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py", line 88, in flores_to_openhab_items
print('\n'.join(items))
UnicodeEncodeError: 'ascii' codec can't encode character '\xb5' in position 844: ordinal not in range(128)

Arch because i wanted to keep the system lean. Thought less software not needed the faster the system will be (Windows user here). Wrong? Wanted to see how much i can run on the little 0W. Planing an irrigation system with node-red, dashboard, mifloras, sonoff switches, weewx, mosquitto, influxdb and grafana.

Like said, fairly new to all this.

Atm i fetch the mqtt msq with a mqtt node (?) in node-red. With a simple non customizable function node i translate json to javascript and process it (atm i dont even rly know why i translate it to java). There are more input nodes like tcp, udp, http, websocket and so on.. what lets me assume that there is no real need for a better connection to node-red. But im the wrong guy to ask

can't encode character '\xb5'

http://www.charbase.com/00b5-unicode-micro-sign

Do you have a µ in your config?

Anyhow, the error shouldn't occur and I'll have another look.

Thought less software not needed the faster the system will

In theory that might be true. However it is hard to configure everything in the best way possible, you might end up with a system hard to maintain and keep up to date with problems every time you want to add a new component. You might be better off using a fitting system for your needs with the right set of tools and settings pre-configured by a big community. Check out raspbian lite (or openhabian, which is raspbian lite with openHAB, mosquitto, node-red, etc. preconfigured).

node-red: okay then. Maybe next time.

Tested with µ in the config. Works just fine on my system. My bet would be that your system locale is not set correctly.

@dingausmwald I've added the commit to show the openHAB items only if asked for via command line argument --gen-openhab. There are some other improvements to the function but since you are not using openHAB yet, they are not worth fetching for you.

@digausmwald any news? Is this issue resolved?

not really, but i haven't tried openHAB or stuff. You shouldnt bother, the problem must have been the arch linux installation made by a newbie (me). Im working with node-red. So far so good, your daemon is running for a good month without problems.

Happy to hear that! Let me know if anything new comes up ;)