Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gas cost type error #26

Merged
merged 1 commit into from
Apr 16, 2023

Commits on Feb 1, 2023

  1. Fix gas cost type error

    - In cases where an IHD is configured for electricity meter only without a gas meter, the gas cost calculations would error
    
    ```
    ...
    in <lambda>
        (js['gasmeter']['energy']['import']['day'] * js['gasmeter']['energy']['import']['price']['unitrate']), 2)
    TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'
    ```
    
    - This was due to the gas values being `null`
    - We now default to `0` for any missing values
    
    Test Plan:
    
    - Manually run the calculation function on the following json sample
    
    ```json
    {
        "gasmeter": {
            "timestamp": "1970-01-01T00:00:00Z",
            "energy": {
                "import": {
                    "cumulative": null,
                    "day": null,
                    "week": null,
                    "month": null,
                    "units": "kWh",
                    "cumulativevol": null,
                    "cumulativevolunits": "",
                    "dayvol": null,
                    "weekvol": null,
                    "monthvol": null,
                    "dayweekmonthvolunits": "",
                    "mprn": "read pending",
                    "supplier": "---",
                    "price": {
                        "unitrate": null,
                        "standingcharge": null
                    }
                }
            }
        }
    }
    ```
    kwridan committed Feb 1, 2023
    Configuration menu
    Copy the full SHA
    b4f8a1c View commit details
    Browse the repository at this point in the history