Giter Club home page Giter Club logo

Comments (16)

jumping2000 avatar jumping2000 commented on July 22, 2024 1

Hi, I'm on holiday! I'll test it after New Years Day. Bye

from bt-mqtt-gateway.

bbbenji avatar bbbenji commented on July 22, 2024

@unconfigured Can you maybe help?
@jumping2000 Please post your config.yaml?

from bt-mqtt-gateway.

jumping2000 avatar jumping2000 commented on July 22, 2024

@bbbenji here my config,yaml

mqtt:
  host: 192.168.1.101
  port: 1883
  username: xxxxxx
  password: xxxxxx
  topic_prefix:
  client_id: bt-mqtt-gateway

manager:
  topic_subscription:
    update_all:
      topic: homeassistant/status
      payload: online
  workers:
    thermostat:
      args:
        devices:
          salotto1: 00:1a:22:0c:XX:XX
          salotto2: 00:1a:22:0f:XX:XX
        topic_prefix: thermostat
      topic_subscription: thermostat/+/+/set
      update_interval: 100
    miflora:
      args:
        devices:
          orchidea: C4:7C:8D:xx:xx:XX
          sansevieria: C4:7C:8D:XX:XX:XX
        topic_prefix: miflora
      update_interval: 600

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

@jumping2000 Looks like you got empty topic_prefix in your config, deleting it should fix that issue. I've also fixed handling case when topic_prefix is empty string, please test this branch https://github.com/zewelor/bt-mqtt-gateway/tree/fix_global_topic_prefix_handling , on your current config ( before removing empty topic_prefix in mqtt config block ).

from bt-mqtt-gateway.

jumping2000 avatar jumping2000 commented on July 22, 2024

@zewelor thank you, this evening I will try the fix :-)
I have a simple request for you and @bbbenji , I wrote a worker module to scan ble devices like nut beacons (I modified the miscale module) , could you help me to implement the scanning of multiple devices?
https://github.com/jumping2000/bt-mqtt-gateway/blob/master/workers/blescan.py

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

@jumping2000 sure I can take a look. Currently I'm on vacation and I will be back in 2 weeks. Here I don't have setup to test it. From quick look at the code:

https://github.com/jumping2000/bt-mqtt-gateway/blob/master/workers/blescan.py#L39 add some array to keep all of the devices, like self._devices = []. Split ScanProcessor into some single device class, only with mac and presence, and build new device each time handleDiscovery finds new device, and add it to the self._devices arrar . Then you can make property with that array and publish mqtt messages, single per each device ? Similar like here: https://github.com/jumping2000/bt-mqtt-gateway/blob/master/workers/thermostat.py#L98 , just return big array of all messages. I think its better to return single device per mqtt message, than one big json payload with all devices.

from bt-mqtt-gateway.

jumping2000 avatar jumping2000 commented on July 22, 2024

@jumping2000 Looks like you got empty topic_prefix in your config, deleting it should fix that issue. I've also fixed handling case when topic_prefix is empty string, please test this branch https://github.com/zewelor/bt-mqtt-gateway/tree/fix_global_topic_prefix_handling , on your current config ( before removing empty topic_prefix in mqtt config block ).

Hi, sorry for the delay, I tried both the master and fix-global-config prefix, but the error is still present when I try to update the temperature of the valve using the Home assistant interface.
I think the problem is related to this topic:
thermostat/salotto1/target_temperature/set
"on command wrapper for with thermostat/salotto1/target_temperature/set: b'16.0'
not enough values to unpack (expected 4, got 3)"

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

Try to delete "topic_prefix:" from your config, as its empty so I assume you are not using it ?

from bt-mqtt-gateway.

jumping2000 avatar jumping2000 commented on July 22, 2024

Try to delete "topic_prefix:" from your config, as its empty so I assume you are not using it ?

I started from scratch;

  1. sudo rm -r bt-mqtt-gateway
  2. git clone https://github.com/zewelor/bt-mqtt-gateway.git
  3. git merge origin/fix_global_topic_prefix_handling
  4. deleted "topic_prefix:" from my config

I have the error whn I try to change temperature or mode:

temperature error


on command wrapper for with thermostat/salotto1/target_temperature/set: b'18.0'
not enough values to unpack (expected 4, got 3)
Traceback (most recent call last):
  File "./gateway.py", line 37, in <module>
    mqtt.publish(_WORKERS_QUEUE.get(block=True).execute())
  File "/home/dietpi/bt-mqtt-gateway/workers_manager.py", line 26, in execute
    messages = self._callback(*self._args)
  File "/home/dietpi/bt-mqtt-gateway/workers/thermostat.py", line 75, in on_command
    _, device_name, method, _ = topic[len(self.topic_prefix+"/"):].split('/')
ValueError: not enough values to unpack (expected 4, got 3)
not enough values to unpack (expected 4, got 3)
Traceback (most recent call last):
  File "./gateway.py", line 37, in <module>
    mqtt.publish(_WORKERS_QUEUE.get(block=True).execute())
  File "/home/dietpi/bt-mqtt-gateway/workers_manager.py", line 26, in execute
    messages = self._callback(*self._args)
  File "/home/dietpi/bt-mqtt-gateway/workers/thermostat.py", line 75, in on_command
    _, device_name, method, _ = topic[len(self.topic_prefix+"/"):].split('/')
ValueError: not enough values to unpack (expected 4, got 3)
on command wrapper for with thermostat/salotto2/target_temperature/set: b'18.0'

mode error

on command wrapper for with thermostat/salotto1/mode/set: b'manual'
not enough values to unpack (expected 4, got 3)
Traceback (most recent call last):
  File "./gateway.py", line 37, in <module>
    mqtt.publish(_WORKERS_QUEUE.get(block=True).execute())
  File "/home/dietpi/bt-mqtt-gateway/workers_manager.py", line 26, in execute
    messages = self._callback(*self._args)
  File "/home/dietpi/bt-mqtt-gateway/workers/thermostat.py", line 75, in on_command
    _, device_name, method, _ = topic[len(self.topic_prefix+"/"):].split('/')
ValueError: not enough values to unpack (expected 4, got 3)
not enough values to unpack (expected 4, got 3)
Traceback (most recent call last):
  File "./gateway.py", line 37, in <module>
    mqtt.publish(_WORKERS_QUEUE.get(block=True).execute())
  File "/home/dietpi/bt-mqtt-gateway/workers_manager.py", line 26, in execute
    messages = self._callback(*self._args)
  File "/home/dietpi/bt-mqtt-gateway/workers/thermostat.py", line 75, in on_command
    _, device_name, method, _ = topic[len(self.topic_prefix+"/"):].split('/')
ValueError: not enough values to unpack (expected 4, got 3)

from bt-mqtt-gateway.

unconfigured avatar unconfigured commented on July 22, 2024

It could be that global and per thermostat "topic_prefixes" are messed up due to my patch which should have fixed the global topic_prefix. I will have a look at it shortly.

from bt-mqtt-gateway.

jumping2000 avatar jumping2000 commented on July 22, 2024

It could be that global and per thermostat "topic_prefixes" are messed up due to my patch which should have fixed the global topic_prefix. I will have a look at it shortly.

thank you!

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

@unconfigured also please take a look at your code with

topic[len(self.topic_prefix+"/"):].split('/')

Now I see possible danger with that style, only len of topic is checked. I think it should be more like regexp with string start to remove start of the string, including "/", when string starts with self.topic_prefix.

from bt-mqtt-gateway.

bbbenji avatar bbbenji commented on July 22, 2024

@jumping2000 Please test the latest commit: 33580dd

from bt-mqtt-gateway.

jumping2000 avatar jumping2000 commented on July 22, 2024

@jumping2000 Please test the latest commit: 33580dd

Hello,
it seems to work!! thank you

on command wrapper for with thermostat/salotto1/target_temperature/set: b'19.5'
on command wrapper for with thermostat/salotto1/target_temperature/set: b'19.5'

[{'topic': 'thermostat/salotto1/low_battery', 'payload': False}, {'topic': 'thermostat/salotto1/valve_state', 'payload': 89}, {'topic': 'thermostat/salotto1/target_temperature', 'payload': 19.5}, {'topic': 'thermostat/salotto1/window_open', 'payload': False}, {'topic': 'thermostat/salotto1/locked', 'payload': False}, {'topic': 'thermostat/salotto1/mode', 'payload': 'heat'}, {'topic': 'thermostat/salotto1/away', 'payload': 'off'}]
[{'topic': 'thermostat/salotto1/low_battery', 'payload': False}, {'topic': 'thermostat/salotto1/valve_state', 'payload': 89}, {'topic': 'thermostat/salotto1/target_temperature', 'payload': 19.5}, {'topic': 'thermostat/salotto1/window_open', 'payload': False}, {'topic': 'thermostat/salotto1/locked', 'payload': False}, {'topic': 'thermostat/salotto1/mode', 'payload': 'heat'}, {'topic': 'thermostat/salotto1/away', 'payload': 'off'}]

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

@jumping2000 we can close that issue ?

from bt-mqtt-gateway.

jumping2000 avatar jumping2000 commented on July 22, 2024

@jumping2000 we can close that issue ?

Yes!! thank you
P.S. with a friend we are testing a new "worker" to scan the BLE devices!

from bt-mqtt-gateway.

Related Issues (20)

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.