thecowan / wallpanel-android

WallPanel is an Android application for Web Based Dashboards and Home Automation Platforms
https://wallpanel.app
Apache License 2.0
741 stars 103 forks source link

Light Sensor data not published #201

Open tadly opened 4 years ago

tadly commented 4 years ago

Describe the bug I managed to receive light data over MQTT exactly 3 times and now it doesn't publish those anymore. I have no idea how I should debug this so help would be appreciated.

I assume it'll come to me having to reset the app and start from scratch, thought I'd ask anyways. Maybe this somehow is a bug after all and needs fixing.

Thanks in advance :)

Before:

...
wallpanel/mywallpanel/state {"currentUrl":"http:\/\/tadly-nas:8123\/lovelace\/0","screenOn":true,"brightness":20}
wallpanel/mywallpanel/sensor/battery {"value":39,"unit":"%","charging":true,"acPlugged":false,"usbPlugged":true}
wallpanel/mywallpanel/sensor/light {"value":173.78125,"unit":"lx","id":"BH1733 Light Sensor"}
wallpanel/mywallpanel/sensor/light {"value":173.78125,"unit":"lx","id":"BH1733 Light Sensor"}
wallpanel/mywallpanel/state {"currentUrl":"http:\/\/tadly-nas:8123\/lovelace\/0","screenOn":true,"brightness":20}
wallpanel/mywallpanel/sensor/battery {"value":39,"unit":"%","charging":true,"acPlugged":false,"usbPlugged":true}
wallpanel/mywallpanel/sensor/light {"value":173.78125,"unit":"lx","id":"BH1733 Light Sensor"}
wallpanel/mywallpanel/sensor/magneticField {"value":190.6,"unit":"uT","id":"MS-3R (YAS532) Magnetic Sensor"}
...

After:

...
wallpanel/tadly-tab-samsung/state {"currentUrl":"http:\/\/tadly-nas:8123\/lovelace\/0","screenOn":true,"brightness":20}
wallpanel/tadly-tab-samsung/sensor/battery {"value":34,"unit":"%","charging":true,"acPlugged":true,"usbPlugged":false}
wallpanel/tadly-tab-samsung/sensor/magneticField {"value":215.20001,"unit":"uT","id":"MS-3R (YAS532) Magnetic Sensor"}
...

To Reproduce Here is what I did in the following order.

  1. Configure MQTT (leaving topic and client-id)
  2. Enable camera motion stuff
  3. Enable publishing of sensor data
  4. Changed MQTT topic and client-id

Expected behavior To get light data sent consistently alongside all other sensor data

Smartphone (please complete the following information):

thanksmister commented 4 years ago

The client ID is used to identify the device with the MQTT broker. It is not used in the topic. You want to instead change your base topic as described in the documentation.

tadly commented 4 years ago

While this might be true, this shouldn't have anything to do with the issue described in OP.

After I put the tab back on the wall it started reporting the light-values alongside everything else again. I haven't changed anything apart from plugging it back in. Not sure if battery vs. power-supply makes a difference. I'll investigate this further tomorrow as I'm quite beat for today :)

thanksmister commented 4 years ago

I think you mentioned wallpanel/mywallpanel/sensor/light was the default setting, then you changed the client id to tadly-tab-samsung and you expected it to publish to wallpanel/tadly-tab-samsung/sensor/battery, but that would not be the case if you just changed the client id.

You would have to change the base topic and topic values to accomplish this. If you are not publishing to the expected command format, then you MQTT broker will not receive it. Please provide a screenshot of your MQTT setting screen in the application and your configuration for your MQTT sensor data in home assistant.

WallPanel publishes state to topic [baseTopic]/state Default Topic: wallpanel/mywallpanel/state

Each sensor publishes to a [baseTopic]/sensor Example: for battery sensor data is published to:wallpanel/mywallpanel/sensor/battery

Your base topic is wallpanel/mywallpanel/, so you would change this to wallpanel/tadly-tab-samsung/ in the base topic field of the application. Then in your configuration for home assistant you would have something like this:

sensor:
  - platform: mqtt
    state_topic: "wallpanel/tadly-tab-samsung/sensor/battery"
    name: "WallPanel Battery Level"
    unit_of_measurement: "%"
    value_template: '{{ value_json.value }}'

I would try it without the special characters as well, instead of tadly-tab-samsung, just use tadlytabsamsung

thanksmister commented 4 years ago

Seems related to this issue https://github.com/thanksmister/wallpanel-android/issues/196, the same expectation that the client id was changing the command/topic for MQTT broker.

tadly commented 4 years ago

I think there's a misunderstanding.

The issue is that wallpanel would not send the light topic while sending everything else (state, battery, magneticField) After plugging it back in, it did start sending light again.

Only thing I can think of for this kind of behaviour is that onSensorChanged wasn't triggering on my device for whatever reason. Haven't spent much time reading the code though.

As it is working now we can probably ignore it and close the issue unless you would want to investigate this further

thanksmister commented 4 years ago

Yeah I understand now thanks. Maybe this is not app related but rather device related. Wondering if that data changes based on the power mode. If on sensor change listener does not report light level it would not be sent. Wall panel just sends the list of sensors it receives.