Odd error in single sensor config in emonhub

You seem to have got to the root of the issue. The alternative solution was to specify datacodes = h, with the trailing comma to indicate it’s a list of length one. Similarly with names = temperature,

Basically, the config file parser configobj is just a little bit cleverer than what people are expecting:

Values can also be lists. Lists are comma separated. You indicate a single member list by a trailing comma, unless you have a config spec that uses force_list, which implies an automatic conversion of scalar values to a single-element list.

This is compounded by the historical decision to have both singular and plural keys to represent the same semantic object. That obviously makes sense in everyday language but it’s not what someone using a computer is expecting.

It’s probably too late to change the way these config values are handled. We can’t use force_list as above because we aren’t validating a spec, we just use whatever data comes out of the config file. I would be too nervous about the unintended consequences of changing how the data is parsed.

1 Like

Thanks Bruce, I’d just stumbled on that same info here:

For simplicity, I’ll use a trailing comma and stick to plurals :slight_smile:

Would it make sense to update the emonhub docs to mention this useful nugget ?

Thanks for investigating.

1 Like

I’d suggest it is essential to do this.

Yes.

I’d not noticed the difference between the singular and the plural either, so I’ll emphasise that in the docs as well.

This will be why the pub and sub channels need the trailing comma!