myhouse-project / myHouse

Home monitoring and automation suite with interactive Slack bot
GNU General Public License v3.0
2 stars 0 forks source link

The order sensors in the same group are displayed #298

Closed user2684 closed 5 years ago

user2684 commented 7 years ago

Reported by: dblanch

Hi, Firstly great product! still getting my head around it but the result is much nicer the the last mysensors controller I was using.

I have a query regarding the order in which layouts return the sensors. I am using the same group of sensors on different widgets on the same page. However the order of the sensors on the widgets is not always the same...so the green line in one graph ends up corresponding the black line in the other graph. And indeed refreshing the widget can change which colours are associated with each sensor.

Is there a way I can fix the sort order so they are always return in the same order?

JSON example:

{
  "module_id": "mod_temperature_summary",
  "section_id": "Sensors",
  "display_name": {
    "en": "Temperature"
  },
  "icon": "fa-thermometer-full",
  "enabled": true,
  "daily_digest": false,
  "auto_refresh_min": 0,
  "widgets": [
    [
      {
        "widget_id": "homesensors_temp_recent",
        "display_name": {
          "en": "Temperature:Timeline:Realtime"
        },
        "enabled": true,
        "size": 12,
        "layout": [
          {
            "type": "sensor_group_timeline",
            "group": "homesensors:homesensors_temp",
            "sensors": [],
            "exclude": [
              "homesensors:homesensors_temp:location_a,range",
              "homesensors:homesensors_temp:location_a,min",
              "homesensors:homesensors_temp:location_b,range",
              "homesensors:homesensors_temp:location_b,min",
              "homesensors:homesensors_temp:location_c,range",
              "homesensors:homesensors_temp:location_c,min"
            ],
            "timeframe": "recent"
          }
        ]
      }
    ],
    [
      {
        "widget_id": "homesensors_temp_history",
        "display_name": {
          "en": "Temperature:Timeline:History"
        },
        "enabled": true,
        "size": 12,
        "layout": [
          {
            "type": "sensor_group_timeline",
            "group": "homesensors:homesensors_temp",
            "sensors": [],
            "exclude": [
              "homesensors:homesensors_temp:location_a,range",
              "homesensors:homesensors_temp:location_a,min",
              "homesensors:homesensors_temp:location_b,range",
              "homesensors:homesensors_temp:location_b,min",
              "homesensors:homesensors_temp:location_c,range",
              "homesensors:homesensors_temp:location_c,min"
            ],
            "timeframe": "history"
          }
        ]
      }
    ]
  ],
  "rules": [],
  "sensors": []
}

user2684 commented 7 years ago

Original comment by: user2684

Hi, thanks for your feedback! I was sure this problem gone a long time ago when "sensors" became an array a few versions ago. The sensors of the group are added in the same order to the chart so they should have the same color provided the configuration is the same like in your case. Do you have a picture to share to show the end result, just to be sure I'm not misunderstanding the issue? Thanks!