Coder Social home page Coder Social logo

etrv2mqtt's People

Contributors

keton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

etrv2mqtt's Issues

AttributeError: 'Client' object has no attribute 'is_connected'

Hi

i am doing some testing with a basic config.json and i get the folowing error:

root@pi:/home/pi/etrv2mqtt# etrv2mqtt config.json
2021-01-06 15:24:48.792 | INFO     | etrv2mqtt.cli:entrypoint:27 - /usr/local/bin/etrv2mqtt is starting
2021-01-06 15:24:48.825 | INFO     | etrv2mqtt.devices:__init__:72 - Adding device t1 MAC: 00:11:22:33:44:55 key: abcabcabcabcabcabcabcabcabc
2021-01-06 15:24:48.830 | INFO     | etrv2mqtt.devices:__init__:72 - Adding device t2 MAC: 00:11:22:33:44:66 key: cacacacacacacacacacacacacacaca
2021-01-06 15:24:48.837 | DEBUG    | etrv2mqtt.mqtt:__init__:32 - connecting to 192.168.1.100:1883
2021-01-06 15:24:49.732 | INFO     | etrv2mqtt.mqtt:_on_connect:49 - Connected to MQTT server
2021-01-06 15:24:50.849 | DEBUG    | etrv2mqtt.devices:poll:39 - Polling data from t1
2021-01-06 15:24:50.855 | DEBUG    | libetrv.device:connect:54 - Trying connect to 00:11:22:33:44:55
2021-01-06 15:25:01.972 | DEBUG    | libetrv.device:send_pin:87 - Write PIN to 00:11:22:33:44:55
2021-01-06 15:25:02.364 | DEBUG    | etrv2mqtt.devices:poll:45 - {"name": "eTRV", "battery": 58, "room_temp": 20.0, "set_point": 20.0, "last_update": "2021-01-06 15:25:02.363597"}
2021-01-06 15:25:02.369 | ERROR    | __main__:<module>:10 - An error has been caught in function '<module>', process 'MainProcess' (18169), thread 'MainThread' (3069663456):

AttributeError: 'Client' object has no attribute 'is_connected'

i have anon the MAC, KEY and IP.

how can i fix this?

regards

support for config

Hi,

Iv realy like to use this rep. with the mqtt interface, as im not in HA.
Iv tryed to config everything as described, but i dont recieve any messages at the topic i have put in the config file.

Isn't this communication trough std. mqtt protocoll? under topic set in the "basic_topic"?

note in my config i have done like this:
scheme:
"base_topic": {
"type":"string",
"description": "base MQTT topic for all thermostats",
"default": "etrv"
},

my config is then:
"base_topic": "Danfoss_ECO2",

is this correct understood?

Thanks
AR

Enhancement: Allow changing settings, time and schedules?

Is it possible to enhance etrv2mqtt to allow full functionality of the app? Currently etrv2mqtt is kind of limited to only set the temperature in manual mode and display some values.

As far as I can see there are the following more possibilities:

  • settings: Allow changing between heating modes (manuel etc.), vacation periods etc.
  • schedules: The thermostats allow setting schedules that run independently on them so you have some kind of autonomity from your smarthome system
  • current time: When you change the batteries, time is lost and needs to be reset. Currently, you need to connect with the Danfoss app to set the time as there is no other possibility to do so.

settings and time seems to be implemented already in cli of libetrv (at least for display but probably it works the same as with temperature?). For the schedule I think there is already something in it (schedule.py) but it looks incomplete to me?

How to publish values

Hi,

At the begining - you did a great job!

I use OpenHab and MQTT.
I can read data from thermostats, but I don't know how to publish new temp value to thermostat.

Is it possible and how topic should looke like?

Thank you in advance for help.

Regards,
Tom

ERROR Message 1 device

Hi,

I have error with one decide other two still works well… message is the following

2023-03-05 21:27:06.561 | ERROR | libetrv.device:connect:95 - Unable connect to 00:04:2F:4F:9B:14. Retrying in 100ms

Device resented…doesn’t heped!

Hope you can help in this!

Helper not started?

Hi

i have been running this ass in a contianer on my hassio for a couple of weeks now and i have had some crashes.

this is the trace stack from the most recent:

`2020-10-12 17:08:38.370 | INFO | etrv2mqtt.devices:set_temperature:55 - Setting Living room left to 10.0C
2020-10-12 17:08:38.370 | ERROR | main::8 - An error has been caught in function '', process 'MainProcess' (7), thread 'MainThread' (139957320365888):
Traceback (most recent call last):

File "/usr/local/bin/etrv2mqtt", line 8, in
sys.exit(entrypoint())
│ │ └ <function entrypoint at 0x7f4a5942ab80>
│ └
└ <module 'sys' (built-in)>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/cli.py", line 28, in entrypoint
main(sys.argv[1])
│ │ └ ['/usr/local/bin/etrv2mqtt', '/data/options.json']
│ └ <module 'sys' (built-in)>
└ <function main at 0x7f4a5a3a93a0>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/cli.py", line 17, in main
deviceManager.poll_forever()
│ └ <function DeviceManager.poll_forever at 0x7f4a59076940>
└ <etrv2mqtt.devices.DeviceManager object at 0x7f4a597a2220>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/devices.py", line 96, in poll_forever
schedule.run_pending()
│ └ <function run_pending at 0x7f4a590761f0>
└ <module 'schedule' from '/usr/local/lib/python3.8/site-packages/schedule/init.py'>
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 563, in run_pending
default_scheduler.run_pending()
│ └ <function Scheduler.run_pending at 0x7f4a59069dc0>
└ <schedule.Scheduler object at 0x7f4a5906ed00>
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 94, in run_pending
self._run_job(job)
│ │ └ Every 2 seconds do _set_temerature_task(<etrv2mqtt.devices.TRVDevice object at 0x7f4a5907a3d0>, 10.0) (last run: [never], nex...
│ └ <function Scheduler._run_job at 0x7f4a590750d0>
└ <schedule.Scheduler object at 0x7f4a5906ed00>
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 147, in _run_job
ret = job.run()
│ └ <function Job.run at 0x7f4a590760d0>
└ Every 2 seconds do _set_temerature_task(<etrv2mqtt.devices.TRVDevice object at 0x7f4a5907a3d0>, 10.0) (last run: [never], nex...
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 466, in run
ret = self.job_func()
│ └ functools.partial(<bound method DeviceManager._set_temerature_task of <etrv2mqtt.devices.DeviceManager object at 0x7f4a597a22...
└ Every 2 seconds do _set_temerature_task(<etrv2mqtt.devices.TRVDevice object at 0x7f4a5907a3d0>, 10.0) (last run: [never], nex...
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/devices.py", line 103, in _set_temerature_task
device.set_temperature(self._mqtt, temperature)
│ │ │ │ └ 10.0
│ │ │ └ <etrv2mqtt.mqtt.Mqtt object at 0x7f4a5907a5e0>
│ │ └ <etrv2mqtt.devices.DeviceManager object at 0x7f4a597a2220>
│ └ <function TRVDevice.set_temperature at 0x7f4a59076790>
└ <etrv2mqtt.devices.TRVDevice object at 0x7f4a5907a3d0>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/devices.py", line 59, in set_temperature
eTRVUtils.set_temperature(self._device, temperature)
│ │ │ │ └ 10.0
│ │ │ └ <libetrv.device.eTRVDevice object at 0x7f4a5907a580>
│ │ └ <etrv2mqtt.devices.TRVDevice object at 0x7f4a5907a3d0>
│ └ <staticmethod object at 0x7f4a592ffa30>
└ <class 'etrv2mqtt.etrvutils.eTRVUtils'>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/etrvutils.py", line 38, in set_temperature
device.temperature.set_point_temperature = float(temperature)
│ │ └ 10.0
│ └ <libetrv.properties.eTRVProperty object at 0x7f4a59306160>
└ <libetrv.device.eTRVDevice object at 0x7f4a5907a580>
File "/usr/local/lib/python3.8/site-packages/libetrv/properties.py", line 22, in get
return self.get_data_object(device).retrieve()
│ │ └ <libetrv.device.eTRVDevice object at 0x7f4a5907a580>
│ └ <function eTRVProperty.get_data_object at 0x7f4a5931d430>
└ <libetrv.properties.eTRVProperty object at 0x7f4a59306160>
File "/usr/local/lib/python3.8/site-packages/libetrv/properties.py", line 59, in retrieve
self.read()
│ └ <function eTRVData.read at 0x7f4a5931da60>
└ <libetrv.data_struct.TemperatureData object at 0x7f4a5882e0d0>
File "/usr/local/lib/python3.8/site-packages/libetrv/properties.py", line 91, in read
data = etrv_read_data(self.device, handler, send_pin, use_encoding)
│ │ │ │ │ └ True
│ │ │ │ └ True
│ │ │ └ 45
│ │ └ <libetrv.device.eTRVDevice object at 0x7f4a5907a580>
│ └ <libetrv.data_struct.TemperatureData object at 0x7f4a5882e0d0>
└ <function etrv_read_data at 0x7f4a5930a4c0>
File "/usr/local/lib/python3.8/site-packages/libetrv/utils.py", line 20, in etrv_read_data
data = device.ble_device.readCharacteristic(handler)
│ │ │ └ 45
│ │ └ <function Peripheral.readCharacteristic at 0x7f4a59458c10>
│ └ <bluepy.btle.Peripheral object at 0x7f4a59429310>
└ <libetrv.device.eTRVDevice object at 0x7f4a5907a580>
File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 529, in readCharacteristic
self._writeCmd("rd %X\n" % handle)
│ │ └ 45
│ └ <function BluepyHelper._writeCmd at 0x7f4a59458040>
└ <bluepy.btle.Peripheral object at 0x7f4a59429310>
File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 302, in _writeCmd
raise BTLEInternalError("Helper not started (did you call connect()?)")
└ <class 'bluepy.btle.BTLEInternalError'>
bluepy.btle.BTLEInternalError: Helper not started (did you call connect()?)`

Outdated libetrv causes crash when decoding eTRV name

I have an eTRV named 'Dør' which causes a crash as libetrv tries to decode the bytes in to ASCII text. This is fixed upstream: AdamStrojek/libetrv@870daa0 so a simple version bump in requirements.txt of libetrv should fix the issue.

2022-04-05 16:00:17.851 | ERROR    | __main__:<module>:8 - An error has been caught in function '<module>', process 'MainProcess' (9), thread 'MainThread' (140217921300288):
Traceback (most recent call last):
> File "/usr/local/bin/etrv2mqtt", line 8, in <module>
    sys.exit(entrypoint())
    │   │    └ <function entrypoint at 0x7f8706593700>
    │   └ <built-in function exit>
    └ <module 'sys' (built-in)>
  File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/cli.py", line 28, in entrypoint
    main(sys.argv[1])
    │    │   └ ['/usr/local/bin/etrv2mqtt', '/data/options.json']
    │    └ <module 'sys' (built-in)>
    └ <function main at 0x7f87073ec3a0>
  File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/cli.py", line 17, in main
    deviceManager.poll_forever()
    │             └ <function DeviceManager.poll_forever at 0x7f8706459b80>
    └ <etrv2mqtt.devices.DeviceManager object at 0x7f87074a8970>
  File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/devices.py", line 94, in poll_forever
    schedule.run_all(delay_seconds=1)
    │        └ <function run_all at 0x7f87064593a0>
    └ <module 'schedule' from '/usr/local/lib/python3.9/site-packages/schedule/__init__.py'>
  File "/usr/local/lib/python3.9/site-packages/schedule/__init__.py", line 787, in run_all
    default_scheduler.run_all(delay_seconds=delay_seconds)
    │                 │                     └ 1
    │                 └ <function Scheduler.run_all at 0x7f87064c7ca0>
    └ <schedule.Scheduler object at 0x7f8706453520>
  File "/usr/local/lib/python3.9/site-packages/schedule/__init__.py", line 118, in run_all
    self._run_job(job)
    │    │        └ Every 3600 seconds do _poll_devices() (last run: [never], next run: 2022-04-05 16:59:56)
    │    └ <function Scheduler._run_job at 0x7f87064c7f70>
    └ <schedule.Scheduler object at 0x7f8706453520>
  File "/usr/local/lib/python3.9/site-packages/schedule/__init__.py", line 172, in _run_job
    ret = job.run()
          │   └ <function Job.run at 0x7f87064590d0>
          └ Every 3600 seconds do _poll_devices() (last run: [never], next run: 2022-04-05 16:59:56)
  File "/usr/local/lib/python3.9/site-packages/schedule/__init__.py", line 661, in run
    ret = self.job_func()
          │    └ functools.partial(<bound method DeviceManager._poll_devices of <etrv2mqtt.devices.DeviceManager object at 0x7f87074a8970>>)
          └ Every 3600 seconds do _poll_devices() (last run: [never], next run: 2022-04-05 16:59:56)
  File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/devices.py", line 82, in _poll_devices
    device.poll(self._mqtt)
    │      │    │    └ <etrv2mqtt.mqtt.Mqtt object at 0x7f8706453b20>
    │      │    └ <etrv2mqtt.devices.DeviceManager object at 0x7f87074a8970>
    │      └ <function TRVDevice.poll at 0x7f8706459940>
    └ <etrv2mqtt.devices.TRVDevice object at 0x7f8706453be0>
  File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/devices.py", line 44, in poll
    ret = eTRVUtils.read_device(self._device)
          │         │           │    └ <libetrv.device.eTRVDevice object at 0x7f8706453b80>
          │         │           └ <etrv2mqtt.devices.TRVDevice object at 0x7f8706453be0>
          │         └ <staticmethod object at 0x7f8706556d30>
          └ <class 'etrv2mqtt.etrvutils.eTRVUtils'>
  File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/etrvutils.py", line 34, in read_device
    return eTRVData(device.name, device.battery, device.temperature.room_temperature, device.temperature.set_point_temperature, datetime.now())
           │        │      │     │      │        │      │                             │      │                                  │        └ <method 'now' of 'datetime.datetime' objects>
           │        │      │     │      │        │      │                             │      │                                  └ <class 'datetime.datetime'>
           │        │      │     │      │        │      │                             │      └ <libetrv.properties.eTRVProperty object at 0x7f870655f490>
           │        │      │     │      │        │      │                             └ <libetrv.device.eTRVDevice object at 0x7f8706453b80>
           │        │      │     │      │        │      └ <libetrv.properties.eTRVProperty object at 0x7f870655f490>
           │        │      │     │      │        └ <libetrv.device.eTRVDevice object at 0x7f8706453b80>
           │        │      │     │      └ <libetrv.properties.eTRVProperty object at 0x7f870655f400>
           │        │      │     └ <libetrv.device.eTRVDevice object at 0x7f8706453b80>
           │        │      └ <libetrv.properties.eTRVProperty object at 0x7f870655f5e0>
           │        └ <libetrv.device.eTRVDevice object at 0x7f8706453b80>
           └ <class 'etrv2mqtt.etrvutils.eTRVData'>
  File "/usr/local/lib/python3.9/site-packages/libetrv/properties.py", line 22, in __get__
    return self.get_data_object(device).retrieve()
           │    │               └ <libetrv.device.eTRVDevice object at 0x7f8706453b80>
           │    └ <function eTRVProperty.get_data_object at 0x7f87065234c0>
           └ <libetrv.properties.eTRVProperty object at 0x7f870655f5e0>
  File "/usr/local/lib/python3.9/site-packages/libetrv/properties.py", line 61, in retrieve
    return self.retrieve_object(self.device)
           │    │               │    └ <libetrv.device.eTRVDevice object at 0x7f8706453b80>
           │    │               └ <libetrv.data_struct.NameData object at 0x7f8705c135b0>
           │    └ <function eTRVSingleData.retrieve_object at 0x7f8706523d30>
           └ <libetrv.data_struct.NameData object at 0x7f8705c135b0>
  File "/usr/local/lib/python3.9/site-packages/libetrv/properties.py", line 129, in retrieve_object
    return getattr(self, self.get_direct_field())
                   │     │    └ <function eTRVSingleData.get_direct_field at 0x7f8706523ca0>
                   │     └ <libetrv.data_struct.NameData object at 0x7f8705c135b0>
                   └ <libetrv.data_struct.NameData object at 0x7f8705c135b0>
  File "/usr/local/lib/python3.9/site-packages/libetrv/fields/base.py", line 22, in __get__
    return self.from_raw_value(raw_value, data)
           │    │              │          └ <libetrv.data_struct.NameData object at 0x7f8705c135b0>
           │    │              └ b'D\xc3\xb8r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
           │    └ <function TextField.from_raw_value at 0x7f8706503b80>
           └ <libetrv.fields.string.TextField object at 0x7f8706529130>
  File "/usr/local/lib/python3.9/site-packages/libetrv/fields/string.py", line 18, in from_raw_value
    return raw_value.decode('ascii').strip('\0')
           │         └ <method 'decode' of 'bytes' objects>
           └ b'D\xc3\xb8r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

Crashes after few hours of working ok

After HA 2022.8.x updates worked fine. Now etrv2mqtt crashes after few hours of operation. I can start it again and then it will again working few hours until again crashes. Log on crash looks like this:

2022-08-24 13:04:36.706 | DEBUG | etrv2mqtt.devices:poll:39 - Polling data from DanfMarianne
2022-08-24 13:04:36.708 | ERROR | main::8 - An error has been caught in function '', process 'MainProcess' (8), thread 'MainThread' (548003052848):
Traceback (most recent call last):

File "/usr/local/bin/etrv2mqtt", line 8, in
sys.exit(entrypoint())
│ │ └ <function entrypoint at 0x7f9602c700>
│ └
└ <module 'sys' (built-in)>
File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/cli.py", line 28, in entrypoint
main(sys.argv[1])
│ │ └ ['/usr/local/bin/etrv2mqtt', '/data/options.json']
│ └ <module 'sys' (built-in)>
└ <function main at 0x7f96ff33a0>
File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/cli.py", line 17, in main
deviceManager.poll_forever()
│ └ <function DeviceManager.poll_forever at 0x7f95ec9b80>
└ <etrv2mqtt.devices.DeviceManager object at 0x7f9702a1f0>
File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/devices.py", line 96, in poll_forever
schedule.run_pending()
│ └ <function run_pending at 0x7f95ec9310>
└ <module 'schedule' from '/usr/local/lib/python3.9/site-packages/schedule/init.py'>
File "/usr/local/lib/python3.9/site-packages/schedule/init.py", line 780, in run_pending
default_scheduler.run_pending()
│ └ <function Scheduler.run_pending at 0x7f95f35c10>
└ <schedule.Scheduler object at 0x7f95ec2580>
File "/usr/local/lib/python3.9/site-packages/schedule/init.py", line 100, in run_pending
self._run_job(job)
│ │ └ Every 3600 seconds do _poll_devices() (last run: 2022-08-24 11:57:28, next run: 2022-08-24 12:57:28)
│ └ <function Scheduler._run_job at 0x7f95f35f70>
└ <schedule.Scheduler object at 0x7f95ec2580>
File "/usr/local/lib/python3.9/site-packages/schedule/init.py", line 172, in _run_job
ret = job.run()
│ └ <function Job.run at 0x7f95ec90d0>
└ Every 3600 seconds do _poll_devices() (last run: 2022-08-24 11:57:28, next run: 2022-08-24 12:57:28)
File "/usr/local/lib/python3.9/site-packages/schedule/init.py", line 661, in run
ret = self.job_func()
│ └ functools.partial(<bound method DeviceManager._poll_devices of <etrv2mqtt.devices.DeviceManager object at 0x7f9702a1f0>>)
└ Every 3600 seconds do _poll_devices() (last run: 2022-08-24 11:57:28, next run: 2022-08-24 12:57:28)
File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/devices.py", line 82, in _poll_devices
device.poll(self._mqtt)
│ │ │ └ <etrv2mqtt.mqtt.Mqtt object at 0x7f95ed7c40>
│ │ └ <etrv2mqtt.devices.DeviceManager object at 0x7f9702a1f0>
│ └ <function TRVDevice.poll at 0x7f95ec9940>
└ <etrv2mqtt.devices.TRVDevice object at 0x7f95ed7130>
File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/devices.py", line 44, in poll
ret = eTRVUtils.read_device(self._device)
│ │ │ └ <libetrv.device.eTRVDevice object at 0x7f95ed7df0>
│ │ └ <etrv2mqtt.devices.TRVDevice object at 0x7f95ed7130>
│ └ <staticmethod object at 0x7f95ff0d90>
└ <class 'etrv2mqtt.etrvutils.eTRVUtils'>
File "/usr/local/lib/python3.9/site-packages/etrv2mqtt/etrvutils.py", line 34, in read_device
return eTRVData(device.name, device.battery, device.temperature.room_temperature, device.temperature.set_point_temperature, datetime.now())
│ │ │ │ │ │ │ │ │ │ └ <method 'now' of 'datetime.datetime' objects>
│ │ │ │ │ │ │ │ │ └ <class 'datetime.datetime'>
│ │ │ │ │ │ │ │ └ <libetrv.properties.eTRVProperty object at 0x7f95ff94f0>
│ │ │ │ │ │ │ └ <libetrv.device.eTRVDevice object at 0x7f95ed7df0>
│ │ │ │ │ │ └ <libetrv.properties.eTRVProperty object at 0x7f95ff94f0>
│ │ │ │ │ └ <libetrv.device.eTRVDevice object at 0x7f95ed7df0>
│ │ │ │ └ <libetrv.properties.eTRVProperty object at 0x7f95ff9460>
│ │ │ └ <libetrv.device.eTRVDevice object at 0x7f95ed7df0>
│ │ └ <libetrv.properties.eTRVProperty object at 0x7f95ff9640>
│ └ <libetrv.device.eTRVDevice object at 0x7f95ed7df0>
└ <class 'etrv2mqtt.etrvutils.eTRVData'>
File "/usr/local/lib/python3.9/site-packages/libetrv/properties.py", line 22, in get
return self.get_data_object(device).retrieve()
│ │ └ <libetrv.device.eTRVDevice object at 0x7f95ed7df0>
│ └ <function eTRVProperty.get_data_object at 0x7f95fbd4c0>
└ <libetrv.properties.eTRVProperty object at 0x7f95ff94f0>
File "/usr/local/lib/python3.9/site-packages/libetrv/properties.py", line 59, in retrieve
self.read()
│ └ <function eTRVData.read at 0x7f95fbdaf0>
└ <libetrv.data_struct.TemperatureData object at 0x7f95699160>
File "/usr/local/lib/python3.9/site-packages/libetrv/properties.py", line 91, in read
data = etrv_read_data(self.device, handler, send_pin, use_encoding)
│ │ │ │ │ └ True
│ │ │ │ └ True
│ │ │ └ 45
│ │ └ <libetrv.device.eTRVDevice object at 0x7f95ed7df0>
│ └ <libetrv.data_struct.TemperatureData object at 0x7f95699160>
└ <function etrv_read_data at 0x7f95fb1d30>
File "/usr/local/lib/python3.9/site-packages/libetrv/utils.py", line 20, in etrv_read_data
data = device.ble_device.readCharacteristic(handler)
│ │ │ └ 45
│ │ └ <function Peripheral.readCharacteristic at 0x7f9605f3a0>
│ └ <bluepy.btle.Peripheral object at 0x7f95ed7280>
└ <libetrv.device.eTRVDevice object at 0x7f95ed7df0>
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 529, in readCharacteristic
self._writeCmd("rd %X\n" % handle)
│ │ └ 45
│ └ <function BluepyHelper._writeCmd at 0x7f9605c790>
└ <bluepy.btle.Peripheral object at 0x7f95ed7280>
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 302, in _writeCmd
raise BTLEInternalError("Helper not started (did you call connect()?)")
└ <class 'bluepy.btle.BTLEInternalError'>
bluepy.btle.BTLEInternalError: Helper not started (did you call connect()?)

In addition, Watchdog -function does not restart service as it should after crash. Have to start it manually.

Newer versions of Home Assistant require timezone info in Last Updated field

Since upgrading to Home Assistant 2021.12, I am receiving errors in my log, because the Last Updated values from etrv2mqtt do not contain timezone information. This means that in Home Assistant, my thermostats will have a value of "Unknown" in the Last Updated field.

This is one of the errors from my logs:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 37, in wrapper
    msg_callback(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/sensor.py", line 249, in message_received
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _async_write_ha_state
    state = self._stringify_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 511, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 411, in state
    raise ValueError(
ValueError: Invalid datetime: sensor.office_last_update provides state '2022-01-15 18:13:28.386640', which is missing timezone information

As far as I can tell, it should be enough to add timezone.utc to the datetime.now() call (timezone needs to be imported from the datetime module).
That would be here:

return eTRVData(device.name, device.battery, device.temperature.room_temperature, device.temperature.set_point_temperature, datetime.now())

Here is my small little test of it:

$ cat timezone-test.py 
from datetime import datetime, timezone

print("Without timezone info:", datetime.now())
print("With timezone info:", datetime.now(timezone.utc))

$ python3 timezone-test.py 
Without timezone info: 2022-01-15 18:34:39.682039
With timezone info: 2022-01-15 17:34:39.682100+00:00

Suggest to loosen the dependency on schedule

Hi, your project etrv2mqtt requires "schedule==0.6.0" in its dependency. After analyzing the source code, we found that the following versions of schedule can also be suitable without affecting your project, i.e., schedule 0.4.3, 0.5.0, 1.0.0. Therefore, we suggest to loosen the dependency on schedule from "schedule==0.6.0" to "schedule>=0.4.3,<=1.0.0" to avoid any possible conflict for importing more packages or for downstream projects that may use etrv2mqtt.

May I pull a request to further loosen the dependency on schedule?

By the way, could you please tell us whether such dependency analysis may be potentially helpful for maintaining dependencies easier during your development?



We also give our detailed analysis as follows for your reference:

Your project etrv2mqtt directly uses 5 APIs from package schedule.

schedule.__init__.clear, schedule.__init__.CancelJob.__init__, schedule.__init__.run_pending, schedule.__init__.every, schedule.__init__.run_all

Beginning from the 5 APIs above, 4 functions are then indirectly called, including 3 schedule's internal APIs and 1 outsider APIs. The specific call graph is listed as follows (neglecting some repeated function occurrences).

[/keton/etrv2mqtt]
+--schedule.__init__.clear
+--schedule.__init__.CancelJob.__init__
+--schedule.__init__.run_pending
+--schedule.__init__.every
+--schedule.__init__.run_all

We scan schedule's versions and observe that during its evolution between any version from [0.4.3, 0.5.0, 1.0.0] and 0.6.0, the changing functions (diffs being listed below) have none intersection with any function or API we mentioned above (either directly or indirectly called by this project).

diff: 0.6.0(original) 0.4.3
['schedule.__init__.ScheduleValueError', 'schedule.__init__.Job.tuesday', 'schedule.__init__.Job.to', 'schedule.__init__.Job.tag', 'schedule.__init__.Job.__repr__', 'schedule.__init__.ScheduleError', 'schedule.__init__.IntervalError', 'schedule.__init__.Job.hour', 'schedule.__init__.Scheduler', 'schedule.__init__.Job.do', 'schedule.__init__.Scheduler.every', 'schedule.__init__.Job.thursday', 'schedule.__init__.Job.sunday', 'schedule.__init__.Job.week', 'schedule.__init__.Job.minute', 'schedule.__init__.Job.day', 'schedule.__init__.Job.at', 'schedule.__init__.Job.friday', 'schedule.__init__.Job', 'schedule.__init__.Job._schedule_next_run', 'schedule.__init__.CancelJob', 'schedule.__init__.Job.__init__', 'schedule.__init__.Job.second', 'schedule.__init__.Job.monday', 'schedule.__init__.Job.saturday', 'schedule.__init__.Job.wednesday']

diff: 0.6.0(original) 0.5.0
['schedule.__init__.ScheduleValueError', 'schedule.__init__.Job.tuesday', 'schedule.__init__.Job.tag', 'schedule.__init__.ScheduleError', 'schedule.__init__.IntervalError', 'schedule.__init__.Job.hour', 'schedule.__init__.Job.thursday', 'schedule.__init__.Job.sunday', 'schedule.__init__.Job.week', 'schedule.__init__.Job.minute', 'schedule.__init__.Job.day', 'schedule.__init__.Job.at', 'schedule.__init__.Job.friday', 'schedule.__init__.Job', 'schedule.__init__.Job._schedule_next_run', 'schedule.__init__.Job.second', 'schedule.__init__.Job.monday', 'schedule.__init__.Job.saturday', 'schedule.__init__.Job.wednesday']

diff: 0.6.0(original) 1.0.0
['schedule.__init__.Job.do', 'schedule.__init__.Scheduler', 'schedule.__init__.Job._schedule_next_run', 'schedule.__init__.Scheduler.run_all', 'schedule.__init__.Job.tag', 'schedule.__init__.Job.run', 'schedule.__init__.Job.__repr__', 'schedule.__init__.Job.at', 'schedule.__init__.Job.__str__', 'schedule.__init__.Scheduler.idle_seconds', 'schedule.__init__.Job', 'schedule.__init__.Scheduler.next_run']

As for other packages, the APIs of time are called by schedule in the call graph and the dependencies on these packages also stay the same in our suggested versions, thus avoiding any outside conflict.

Therefore, we believe that it is quite safe to loose your dependency on schedule from "schedule==0.6.0" to "schedule>=0.4.3,<=1.0.0". This will improve the applicability of etrv2mqtt and reduce the possibility of any further dependency conflict with other projects.

_main__:<module>:8 - An error has been caught in function '<module>', process 'MainProcess' (7), thread 'MainThread' (140051042436928):

2021-08-15 18:14:09.330 | DEBUG | libetrv.device:send_pin:87 - Write PIN to 00:04:2f:94:95:5b
2021-08-15 18:14:09.528 | ERROR | main::8 - An error has been caught in function '', process 'MainProcess' (7), thread 'MainThread' (140051042436928):
Traceback (most recent call last):

File "/usr/local/bin/etrv2mqtt", line 8, in
sys.exit(entrypoint())
│ │ └ <function entrypoint at 0x7f602b5caca0>
│ └
└ <module 'sys' (built-in)>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/cli.py", line 28, in entrypoint
main(sys.argv[1])
│ │ └ ['/usr/local/bin/etrv2mqtt', '/data/options.json']
│ └ <module 'sys' (built-in)>
└ <function main at 0x7f602c8004c0>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/cli.py", line 17, in main
deviceManager.poll_forever()
│ └ <function DeviceManager.poll_forever at 0x7f602b30fd30>
└ <etrv2mqtt.devices.DeviceManager object at 0x7f602b5f2670>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/devices.py", line 94, in poll_forever
schedule.run_all(delay_seconds=1)
│ └ <function run_all at 0x7f602b30f550>
└ <module 'schedule' from '/usr/local/lib/python3.8/site-packages/schedule/init.py'>
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 787, in run_all
default_scheduler.run_all(delay_seconds=delay_seconds)
│ │ └ 1
│ └ <function Scheduler.run_all at 0x7f602b2fce50>
└ <schedule.Scheduler object at 0x7f602b304a90>
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 118, in run_all
self._run_job(job)
│ │ └ Every 3600 seconds do _poll_devices() (last run: [never], next run: 2021-08-15 19:13:58)
│ └ <function Scheduler._run_job at 0x7f602b30d160>
└ <schedule.Scheduler object at 0x7f602b304a90>
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 172, in _run_job
ret = job.run()
│ └ <function Job.run at 0x7f602b30f280>
└ Every 3600 seconds do _poll_devices() (last run: [never], next run: 2021-08-15 19:13:58)
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 661, in run
ret = self.job_func()
│ └ functools.partial(<bound method DeviceManager._poll_devices of <etrv2mqtt.devices.DeviceManager object at 0x7f602b5f2670>>)
└ Every 3600 seconds do _poll_devices() (last run: [never], next run: 2021-08-15 19:13:58)
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/devices.py", line 82, in _poll_devices
device.poll(self._mqtt)
│ │ │ └ <etrv2mqtt.mqtt.Mqtt object at 0x7f602b3141c0>
│ │ └ <etrv2mqtt.devices.DeviceManager object at 0x7f602b5f2670>
│ └ <function TRVDevice.poll at 0x7f602b30faf0>
└ <etrv2mqtt.devices.TRVDevice object at 0x7f602b627d30>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/devices.py", line 44, in poll
ret = eTRVUtils.read_device(self._device)
│ │ │ └ <libetrv.device.eTRVDevice object at 0x7f602c8634c0>
│ │ └ <etrv2mqtt.devices.TRVDevice object at 0x7f602b627d30>
│ └ <staticmethod object at 0x7f602b58f430>
└ <class 'etrv2mqtt.etrvutils.eTRVUtils'>
File "/usr/local/lib/python3.8/site-packages/etrv2mqtt/etrvutils.py", line 34, in read_device
return eTRVData(device.name, device.battery, device.temperature.room_temperature, device.temperature.set_point_temperature, datetime.now())
│ │ │ │ │ │ │ │ │ │ └ <method 'now' of 'datetime.datetime' objects>
│ │ │ │ │ │ │ │ │ └ <class 'datetime.datetime'>
│ │ │ │ │ │ │ │ └ <libetrv.properties.eTRVProperty object at 0x7f602b58fb50>
│ │ │ │ │ │ │ └ <libetrv.device.eTRVDevice object at 0x7f602c8634c0>
│ │ │ │ │ │ └ <libetrv.properties.eTRVProperty object at 0x7f602b58fb50>
│ │ │ │ │ └ <libetrv.device.eTRVDevice object at 0x7f602c8634c0>
│ │ │ │ └ <libetrv.properties.eTRVProperty object at 0x7f602b58fac0>
│ │ │ └ <libetrv.device.eTRVDevice object at 0x7f602c8634c0>
│ │ └ <libetrv.properties.eTRVProperty object at 0x7f602b58fca0>
│ └ <libetrv.device.eTRVDevice object at 0x7f602c8634c0>
└ <class 'etrv2mqtt.etrvutils.eTRVData'>
File "/usr/local/lib/python3.8/site-packages/libetrv/properties.py", line 22, in get
return self.get_data_object(device).retrieve()
│ │ └ <libetrv.device.eTRVDevice object at 0x7f602c8634c0>
│ └ <function eTRVProperty.get_data_object at 0x7f602b5ae0d0>
└ <libetrv.properties.eTRVProperty object at 0x7f602b58fca0>
File "/usr/local/lib/python3.8/site-packages/libetrv/properties.py", line 61, in retrieve
return self.retrieve_object(self.device)
│ │ │ └ <libetrv.device.eTRVDevice object at 0x7f602c8634c0>
│ │ └ <libetrv.data_struct.NameData object at 0x7f602aab3490>
│ └ <function eTRVSingleData.retrieve_object at 0x7f602b5ae940>
└ <libetrv.data_struct.NameData object at 0x7f602aab3490>
File "/usr/local/lib/python3.8/site-packages/libetrv/properties.py", line 129, in retrieve_object
return getattr(self, self.get_direct_field())
│ │ └ <function eTRVSingleData.get_direct_field at 0x7f602b5ae8b0>
│ └ <libetrv.data_struct.NameData object at 0x7f602aab3490>
└ <libetrv.data_struct.NameData object at 0x7f602aab3490>
File "/usr/local/lib/python3.8/site-packages/libetrv/fields/base.py", line 22, in get
return self.from_raw_value(raw_value, data)
│ │ │ └ <libetrv.data_struct.NameData object at 0x7f602aab3490>
│ │ └ b'sovev\xc3\xa6relse\x00\x00\x00\x00'
│ └ <function TextField.from_raw_value at 0x7f602b5ac790>
└ <libetrv.fields.string.TextField object at 0x7f602b5adee0>
File "/usr/local/lib/python3.8/site-packages/libetrv/fields/string.py", line 18, in from_raw_value
return raw_value.decode('ascii').strip('\0')
│ └ <method 'decode' of 'bytes' objects>
└ b'sovev\xc3\xa6relse\x00\x00\x00\x00'
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)

Python version problem

At first im installing Adam's libertv (your library is using part of it so i assumed that is necessary)

$ mkdir -p ~/venv/libetrv
$ python3 -m venv ~/venv/libetrv
$ source ~/venv/libetrv/bin/activate
$ cd ~/venv/libetrv
$ git clone https://github.com/AdamStrojek/libetrv.git
$ cd cd libetrv/
$ pip3 install -r requirements.txt

For now, everything is working fine. Now i start to install your lib.

mkdir -p ~/venv/etrv2mqtt
virtualenv ~/venv/etrv2mqtt
created virtual environment CPython3.6.5.final.0-32 in 2148ms creator CPython3Posix(dest=/home/pi/venv/etrv2mqtt, clear=False, global=False) seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/home/pi/.local/share/virtualenv/seed-app-data/v1.0.1) activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

~/venv/etrv2mqtt/bin/pip3 install 'git+https://github.com/keton/etrv2mqtt.git'

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting git+https://github.com/keton/etrv2mqtt.git Cloning https://github.com/keton/etrv2mqtt.git to /tmp/pip-req-build-as88nucd Running command git clone -q https://github.com/keton/etrv2mqtt.git /tmp/pip-req-build-as88nucd ERROR: Package 'etrv2mqtt' requires a different Python: 3.6.5 not in '>=3.7'
According to error i recieve my python ver. is different than required. I tried to install with 3.7.X but without succes. For now its a bit too late to go deep with that but if you wish i can try it again tommorow.

Turn off ringlight

Hey

Is it possible to turn off the ringlight on the thermostats?
I have some that are blinking and some that are constant on. What does this mean?

Doesnt run under python 3.10

Python 3.10 gives:

(etrv2mqtt) [root@HomeAssistant etrv2mqtt]# ~/venv/etrv2mqtt/bin/python3 -m libetrv.cli scan
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/root/venv/etrv2mqtt/lib/python3.10/site-packages/libetrv/cli.py", line 3, in
from libetrv.device import eTRVDevice
File "/root/venv/etrv2mqtt/lib/python3.10/site-packages/libetrv/device.py", line 8, in
from .data_struct import BatteryData, SettingsData, TemperatureData, CurrentTimeData, SecretKeyData, NameData
File "/root/venv/etrv2mqtt/lib/python3.10/site-packages/libetrv/data_struct.py", line 3, in
from .properties import eTRVData, eTRVSingleData
File "/root/venv/etrv2mqtt/lib/python3.10/site-packages/libetrv/properties.py", line 5, in
from .utils import etrv_read_data, etrv_write_data
File "/root/venv/etrv2mqtt/lib/python3.10/site-packages/libetrv/utils.py", line 1, in
from collections import Iterable
ImportError: cannot import name 'Iterable' from 'collections' (/usr/lib/python3.10/collections/init.py)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.