erkexzcx / valetudopng

A Valetudo map renderer (ex Hypfer/ICantBelieveItsNotValetudo) for Home Assistant.
https://valetudo.cloud/
Apache License 2.0
42 stars 6 forks source link

json: cannot unmarshal number #1

Closed osmfarid closed 1 year ago

osmfarid commented 1 year ago

Hello, I try to start version 1.0.4 (amd64), but there is an error

Robot: Mi Robot Vacuum Mop P (Viomi V8) Valetudo: 2023.08.0

Valetudo's exported map (part with problem): (I can attach complete file if you need)

  "entities": [
    {
      "__class": "PointMapEntity",
      "metaData": {
        "angle": 178.51663517951965
      },
      "points": [
        1987,
        1965
      ],
      "type": "robot_position"
    },
    {
      "__class": "PointMapEntity",
      "metaData": {
        "angle": 178.51663517951965
      },
      "points": [
        1988,
        1980
      ],
      "type": "charger_location"
    },
]

Output:

2023/10/02 09:36:51 [MQTT consumer] Connected
2023/10/02 09:36:51 [MQTT producer] Connected
2023/10/02 09:36:51 [MQTT consumer] Subscribed to map data topic
2023/10/02 09:36:51 Error occurred while rendering map: json: cannot unmarshal number 178.51663517951965 into Go struct field MetaDataEntity.entities.metaData.angle of type int

Thanks!

erkexzcx commented 1 year ago

Hi. Thanks for reporting. Sounds like we need to parse angle as float64 rather than int. Let me update it.

erkexzcx commented 1 year ago
         {
            "__class":"PointMapEntity",
            "metaData":{

            },
            "points":[
               2597,
               2570
            ],
            "type":"charger_location"
         },
         {
            "__class":"PointMapEntity",
            "metaData":{
               "angle":144
            },
            "points":[
               2457,
               2682
            ],
            "type":"robot_position"
         }

In your case, both charger and robot have angles. In my case only a robot.

Let's ignore (as we already do) charger's angle and consider robot's angle as a whole number (without decimals). Let me update the code and push a new release, so you can try.

erkexzcx commented 1 year ago

v1.0.5 released. In few minutes binaries will be ready. Docker images will be ready in 10 minutes. :)

Reopen if issue still persists or there is another field that causes fatal error.

osmfarid commented 1 year ago

Works like a charm! Thanks!