SigFox component

Page for discussion on the Sigfox component.

SigFox is a service for publishing short messages (12 bytes) over long range with low power. I am using a pycom LoPy4.

Hi,
I got an error from your component

sigfox: Error on device update!

Traceback (most recent call last):
_ File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 244, in async_add_entity
_ await entity.async_device_update(warning=False)_
_ File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 327, in async_device_update_
_ yield from self.hass.async_add_job(self.update)_
_ File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter_
_ yield self # This tells Task to wait for completion._
_ File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in wakeup
_ future.result()_
_ File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result_
_ raise self.exception
_ File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run_
_ result = self.fn(*self.args, **self.kwargs)_
_ File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/sigfox.py”, line 145, in update_
_ self.message_data = self.get_last_message()
_ File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/sigfox.py”, line 132, in get_last_message_
_ payload = bytes.fromhex(data[‘data’]).decode(‘utf-8’)_
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x8e in position 0: invalid start byte

What is your configuration on the sigfox backend ?

@robmarkcole Can this be operated via battery?

@lhanneus can you clarify the info you are after? Can you provide into on the payload?

@bachoo786 sigfox devices can be battery powered, see the hackster.io channel

You mean this ?

@lhanneus mine appears to be encoded differently:

On https://backend.sigfox.com/devicetype/list I have:

How about yours?

I use a “custom grammar” with this kind of decode

temp::uint:8 humid::uint:8 batt::uint:8

I take a look at your sigfox.py file
Do you use this component only for GPS position ? Then it should be clearly identified. Homeassistant has a “presence detection” category for those kinds of component.
Sigfox could carry any kind of message …

You should then also publish the code with your LoPy4 Pycom device and I’m pretty sure it’s attached to a pytrack ?

It is attached to a pytrack, although that GPS coordinate is the sigfox basestation rather than a reading from the pytrack. I’m using this component to monitor sensor readings delivered in the payload.

If you can submit a PR for handling custom encodings I am happy to review

@lhanneus any further thoughts on encoding? Can you send a regular ASCII encoded message and decode in HA?

Hi @robmarkcole, I’ll need time, I’m moving so all my stuff are in boxes. I hope to continue in some days.

Thanks in advance for your help.

1 Like

Hi @lhanneus

I’ve the same problem.

I’m using an Arduino MKRFOX1200 as a meteorological station sending temperature, pressure, humid and altitude using a “custom grammar” simillar to yours, and for example my payload is "0033332941889f1113beac00 "

My Home Assistant error is:

payload = bytes.fromhex(data[‘data’]).decode(‘utf-8’)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x84 in position 5: invalid start byte

@robmarkcole Any help?

HI @Pharizna the component doesn’t support custom encoding, as I didn’t even know about custom encoding when writing the component. I suggest you use regular encoding and use a HA template to decode the payload, but I haven’t tried this myself

Thank you @robmarkcole … but how can I send data about 5 sensors in just only message using regular encoding?

Would it be possible to read in HA just the “ascii” message?
0033332941889f1113beac00

Would it be enough removing the decode section of your command?
payload = bytes.fromhex(data[‘data’]).decode(‘utf-8’) -> payload = bytes.fromhex(data[‘data’])

Could I use a template to read bytes?

I’ve not tried myself but expect its possible, if you get it working could you submit a PR?
The sigfox component is an MVP for a project I’m working on (slowly!)

Hi @lhanneus

Have you solve the decoding of your ‘custom grammar’?

I can read now the payload long string from Sigfox.

I’m using this ‘custom grammar’ and I don’t know how to extract, for example, the ‘5138’ substring in order to convert it to “14417” in decimal format :slight_smile:

Thank in advance you for your help to write the right template

Solved it myself :slight_smile:

  - platform: template
    sensors:
      sigfox_temp:
        friendly_name: Temperatura
        value_template: '{% set temp= states("sensor.mkrfox_18ba5a")[6:9] + states("sensor.mkrfox_18ba5a")[3:6] %}
                         {% set valor=temp|int(value,16)/32767*55-5 %}
                         {{"%0.1f"| format(valor|float)}}'
        icon_template: mdi:thermometer
        unit_of_measurement: "ºC"
1 Like

I’m curious, I see that @Pharizna use MKRFOX Arduino, what are other setup ?

I want to use Sigfox with presence detection sensor + DHT22 and I wonder if there is another cheaper way than Arduino Fox.

I’m using a Pycom Lopy4

1 Like