WallPanel-Project / wallpanel-android

This project is deprecated; try out this active fork: https://thanksmister.com/wallpanel-android/
Apache License 2.0
207 stars 27 forks source link

Pressure and brightness not posted via mqtt #41

Open tringler opened 6 years ago

tringler commented 6 years ago

Can anyone confirm that brightness and pressure is not working for some devices? On my Samsung TAB S 8.4 the battery status is sent by mqtt while pressure and brightness mqtt sensor don't get any data:

- platform: mqtt
  state_topic: "wallpanel/floor/sensor/battery"
  name: "floor_wallpanel_battery"
  unit_of_measurement: "%"
  value_template: '{{ value_json.value }}'

- platform: mqtt
  state_topic: "wallpanel/floor/sensor/brightness"
  name: "floor_wallpanel_brightness"
  unit_of_measurement: "lx"
  value_template: '{{ value_json.value }}'

- platform: mqtt
  state_topic: "wallpanel/floor/sensor/pressure"
  name: "wallpanel pressure"
  unit_of_measurement: "mb"
  value_template: '{{ value_json.value }}'
tringler commented 6 years ago

@quadportnick It went out that i.e. on my device the event.value[0] for the light sensor is empty. I "solved" it like that:

    private void getSensorReadings() {
        Log.d(TAG, "getSensorReadings called");
        for (Sensor sensor : mSensorList) {
            mSensorManager.registerListener(new SensorEventListener(){
                @Override
                public void onSensorChanged(SensorEvent event) {
                    JSONObject data = new JSONObject();
                    try {
                        if (event.values[0] != 0.0) {
                            data.put(VALUE, event.values[0]);
                        } else {
                            data.put(VALUE, event.values[1]);
                        }
                        data.put(UNIT, "??"); // todo not useful units :)
                        data.put(ID, event.sensor.getName());
                    }
                    catch (JSONException ex) { ex.printStackTrace(); }

                    publishSensorData(getSensorName(event.sensor.getType()), data);
                    mSensorManager.unregisterListener(this);
                }

                @Override
                public void onAccuracyChanged(Sensor sensor, int accuracy) {}
            }, sensor, 1000);
        }
    }
quadportnick commented 6 years ago

I love the peculiarity on this stuff between devices. I'll get that integrated, thanks!

tringler commented 6 years ago

@quadportnick Thanks! Glad to know the project is not dead yet 👍

quadportnick commented 6 years ago

Commited in https://github.com/WallPanel-Project/wallpanel-android/commit/762fa4f09e60f5508d5cf6fc8cc9d507bfcecf7c

quadportnick commented 6 years ago

Test release: https://github.com/WallPanel-Project/wallpanel-android/releases/tag/0.7b1

manojjenago commented 6 years ago

Hi , I have installed the .7b1 version and I have the same problem where Pressure and brightness not posted via mqtt. I am using core-mosquitto as my mqtt broker. Please guide..

Thanks,

apolci commented 4 years ago

I'm using v0.9.3 on Samsung Galaxy A3 and I have the same problem.