Skip to content

Commit

Permalink
Merge branch 'bug/tz'
Browse files Browse the repository at this point in the history
  • Loading branch information
unsync committed Jan 26, 2024
2 parents e2c1fa8 + fa782bf commit a160916
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: publish package

on:
workflow_dispatch:
push:
branches:
- main
Expand Down
8 changes: 7 additions & 1 deletion src/veolia.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { getLogger } from '@unsync/nodejs-tools'
import type { Dayjs } from 'dayjs'
import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc.js'
import { XMLBuilder, XMLParser } from 'fast-xml-parser'
import { httpRequest } from './http-client.js'

dayjs.extend(utc)

export interface EnergyDataPoint {
start: string
state: number
Expand Down Expand Up @@ -91,8 +94,11 @@ export class VeoliaClient {
}

return soapBody.map((r: any) => {
const dateReleveLocal = dayjs(r.dateReleve)
const dateReleveUTC = dateReleveLocal.add(dateReleveLocal.utcOffset(), 'minute').utc()
this.logger.info(`VeoliaClient > getEnergyData > ${dateReleveUTC.toISOString()}: ${r.consommation}`)
return {
start: dayjs(r.dateReleve).startOf('day').add(12, 'hour').toISOString(),
start: dateReleveUTC.set('hour', 10).toISOString(),
state: r.consommation,
// veolia set the index to the start of the day,
// so we need to add the consumption to get the end of the day index
Expand Down
2 changes: 1 addition & 1 deletion test/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export const mockEnergyData = '\n'
+ 'Content-Transfer-Encoding: binary\n'
+ 'Content-ID: <[email protected]>\n'
+ '\n'
+ '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getConsommationJournaliereResponse xmlns:ns2="http://ws.icl.veolia.com/"><return><codeRetour>00</codeRetour><consommation>200</consommation><dateReleve>2023-10-26T00:00:00+02:00</dateReleve><fiabiliteIndex>M</fiabiliteIndex><index>34374</index></return><return><codeRetour>00</codeRetour><consommation>142</consommation><dateReleve>2023-10-27T00:00:00+02:00</dateReleve><fiabiliteIndex>M</fiabiliteIndex><index>34574</index></return></ns2:getConsommationJournaliereResponse></soap:Body></soap:Envelope>\n'
+ '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getConsommationJournaliereResponse xmlns:ns2="http://ws.icl.veolia.com/"><return><codeRetour>00</codeRetour><consommation>200</consommation><dateReleve>2023-10-26T00:00:00+02:00</dateReleve><fiabiliteIndex>M</fiabiliteIndex><index>34374</index></return><return><codeRetour>00</codeRetour><consommation>142</consommation><dateReleve>2023-10-29T00:00:00+02:00</dateReleve><fiabiliteIndex>M</fiabiliteIndex><index>34574</index></return></ns2:getConsommationJournaliereResponse></soap:Body></soap:Envelope>\n'
+ '--uuid:8ad230ff-7d22-45bf-9e5e-19161316f835--'
2 changes: 1 addition & 1 deletion test/veolia.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ it('should fetch data', async () => {
state: 200,
sum: 34574,
}, {
start: '2023-10-27T10:00:00.000Z',
start: '2023-10-29T10:00:00.000Z',
state: 142,
sum: 34716,
}],
Expand Down

0 comments on commit a160916

Please sign in to comment.